Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup compare simulations #5708

Merged
merged 10 commits into from
Dec 4, 2024
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { WorkflowOperationTypes } from '@/types/workflow';
import type { Operation, BaseState } from '@/types/workflow';

export interface CompareDatasetsState extends BaseState {}

export const CompareDatasetsOperation: Operation = {
name: WorkflowOperationTypes.COMPARE_DATASETS,
displayName: 'Compare datasets',
description: 'Compare datasets, or simulation results',
documentationUrl: '',
inputs: [
{ type: 'datasetId', label: 'Dataset or Simulation result' },
{ type: 'datasetId', label: 'Dataset or Simulation result' }
],
outputs: [{ type: 'datasetId', label: 'Dataset' }],
isRunnable: true,
action: () => {},
initState: () => {
const init: CompareDatasetsState = {};
return init;
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { CompareDatasetsOperation as operation } from './compare-datasets-operation';
import node from './tera-compare-datasets-node.vue';
import drilldown from './tera-compare-datasets-drilldown.vue';

const name = operation.name;

export { name, operation, node, drilldown };
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<template>
<tera-drilldown
:node="node"
@on-close-clicked="emit('close')"
@update-state="(state: any) => emit('update-state', state)"
>
TBD
</tera-drilldown>
</template>

<script setup lang="ts">
import TeraDrilldown from '@/components/drilldown/tera-drilldown.vue';
import { WorkflowNode } from '@/types/workflow';
import { CompareDatasetsState } from './compare-datasets-operation';

// const props =
defineProps<{
node: WorkflowNode<CompareDatasetsState>;
}>();

const emit = defineEmits(['update-state', 'update-status', 'close']);
</script>

<style scoped></style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<template>
<section>
<tera-operator-placeholder :node="node">Attach datasets/simulation outputs to compare</tera-operator-placeholder>
shawnyama marked this conversation as resolved.
Show resolved Hide resolved
<Button v-if="hasAtLeastTwoValues" label="Open" @click="emit('open-drilldown')" severity="secondary" outlined />
</section>
</template>

<script setup lang="ts">
import { computed, watch } from 'vue';
import { type WorkflowNode, WorkflowPortStatus } from '@/types/workflow';
import TeraOperatorPlaceholder from '@/components/operator/tera-operator-placeholder.vue';
import Button from 'primevue/button';
import { CompareDatasetsState } from './compare-datasets-operation';

const props = defineProps<{
node: WorkflowNode<CompareDatasetsState>;
}>();

const emit = defineEmits(['append-input-port', 'open-drilldown']);

const hasAtLeastTwoValues = computed(() => props.node.inputs.filter((input) => input.value).length >= 2);

watch(
() => props.node.inputs,
() => {
if (props.node.inputs.every((input) => input.status === WorkflowPortStatus.CONNECTED)) {
emit('append-input-port', { type: 'datasetId', label: 'Dataset or Simulation result' });
}
},
{ deep: true }
);
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { watch, computed } from 'vue';
import Button from 'primevue/button';
import TeraOperatorPlaceholder from '@/components/operator/tera-operator-placeholder.vue';
import { WorkflowNode, WorkflowPortStatus } from '@/types/workflow';
import { type WorkflowNode, WorkflowPortStatus } from '@/types/workflow';
import { ModelComparisonOperationState } from './model-comparison-operation';

const emit = defineEmits(['append-input-port', 'open-drilldown']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ import * as OptimizeCiemssOp from '@/components/workflow/ops/optimize-ciemss/mod
import * as DocumentOp from '@/components/workflow/ops/document/mod';
import * as ModelFromDocumentOp from '@/components/workflow/ops/model-from-equations/mod';
import * as ModelComparisonOp from '@/components/workflow/ops/model-comparison/mod';
import * as CompareDatasetsOp from '@/components/workflow/ops/compare-datasets/mod';
import * as InterventionPolicyOp from '@/components/workflow/ops/intervention-policy/mod';
import { subscribe, unsubscribe } from '@/services/ClientEventService';
import { activeProjectId } from '@/composables/activeProject';
Expand All @@ -230,6 +231,7 @@ registry.registerOp(DocumentOp);
registry.registerOp(ModelFromDocumentOp);
registry.registerOp(ModelComparisonOp);
registry.registerOp(InterventionPolicyOp);
registry.registerOp(CompareDatasetsOp);

// Will probably be used later to save the workflow in the project
const props = defineProps<{
Expand Down Expand Up @@ -549,6 +551,10 @@ const contextMenuItems: MenuItem[] = [
{
label: CalibrateEnsembleCiemssOp.operation.displayName,
command: addOperatorToWorkflow(CalibrateEnsembleCiemssOp)
},
{
label: CompareDatasetsOp.operation.displayName,
command: addOperatorToWorkflow(CompareDatasetsOp)
}
]
},
Expand Down
3 changes: 2 additions & 1 deletion packages/client/hmi-client/src/types/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export const WorkflowOperationTypes = Object.freeze({
DOCUMENT: 'Document',
MODEL_FROM_EQUATIONS: 'ModelFromEquations',
REGRIDDING: 'Regridding',
INTERVENTION_POLICY: 'InterventionPolicy'
INTERVENTION_POLICY: 'InterventionPolicy',
COMPARE_DATASETS: 'CompareDatasets'
});

export enum OperatorStatus {
Expand Down