From 93fa8e48284f03f55c6d55a42ee3a19da92594cf Mon Sep 17 00:00:00 2001 From: Adrian Date: Thu, 14 Nov 2024 14:01:02 -0500 Subject: [PATCH 1/6] fix for config saving issue --- .../tera-model-config-drilldown.vue | 9 +++++++ .../src/services/model-configurations.ts | 25 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/packages/client/hmi-client/src/components/workflow/ops/model-config/tera-model-config-drilldown.vue b/packages/client/hmi-client/src/components/workflow/ops/model-config/tera-model-config-drilldown.vue index e1f946c54d..b37e0ca9e5 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/model-config/tera-model-config-drilldown.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/model-config/tera-model-config-drilldown.vue @@ -257,6 +257,7 @@ import { createModelConfiguration, getArchive, getMissingInputAmount, + getMmtParameters, getModelConfigurationById, setInitialExpression, setInitialSource, @@ -632,6 +633,10 @@ const initialize = async (overwriteWithState: boolean = false) => { knobs.value.transientModelConfig = cloneDeep(state.transientModelConfig); } } + const parameters = getMmtParameters(knobs.value.transientModelConfig, mmt.value, mmtParams.value); + if (parameters.length) { + knobs.value.transientModelConfig.parameterSemanticList = parameters; + } configuredMmt.value = makeConfiguredMMT(mmt.value, knobs.value.transientModelConfig); @@ -656,6 +661,10 @@ const onSelectConfiguration = async (config: ModelConfiguration) => { pdfViewer.value.goToPage(config.extractionPage); } + const parameters = getMmtParameters(knobs.value.transientModelConfig, mmt.value, mmtParams.value); + if (parameters.length) { + knobs.value.transientModelConfig.parameterSemanticList = parameters; + } const { transientModelConfig } = knobs.value; // If no changes were made switch right away if (isModelConfigsEqual(originalConfig, transientModelConfig)) { diff --git a/packages/client/hmi-client/src/services/model-configurations.ts b/packages/client/hmi-client/src/services/model-configurations.ts index 9d1db431f0..b863787768 100644 --- a/packages/client/hmi-client/src/services/model-configurations.ts +++ b/packages/client/hmi-client/src/services/model-configurations.ts @@ -7,8 +7,10 @@ import type { ObservableSemantic, ParameterSemantic } from '@/types/Types'; +import { SemanticType } from '@/types/Types'; import { isEmpty, isNaN, isNumber } from 'lodash'; import { pythonInstance } from '@/python/PyodideController'; +import { collapseParameters } from '@/model-representation/mira/mira'; import { DistributionType } from './distribution'; export interface SemanticOtherValues { @@ -235,3 +237,26 @@ export function getMissingInputAmount(modelConfiguration: ModelConfiguration) { }); return missingInputs; } + +export function getMmtParameters(modelConfiguration, mmt, mmtParams) { + const collapsedParameters = collapseParameters(mmt, mmtParams); + const parameters = getParameters(modelConfiguration); + return Array.from(collapsedParameters.keys()).map((id) => { + const childIds = collapsedParameters.get(id) ?? []; + const childParameters = childIds + .map((childId) => parameters.find((p) => p.referenceId === childId)) + .filter(Boolean) as ParameterSemantic[]; + const parameter = { + default: false, + distribution: { + type: DistributionType.Constant, + parameters: { value: mmt.parameters?.[childIds[0]]?.value ?? 0 } + }, + referenceId: id, + type: SemanticType.Parameter, + source: mmt.annotations.name + }; + + return childParameters.length ? { ...childParameters[0] } : parameter; + }); +} From a07625cb3015d92f6e9238ebbaf4f41a57b6acff Mon Sep 17 00:00:00 2001 From: Adrian Date: Thu, 14 Nov 2024 14:10:10 -0500 Subject: [PATCH 2/6] remove default value on parameter --- packages/client/hmi-client/src/services/model-configurations.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/client/hmi-client/src/services/model-configurations.ts b/packages/client/hmi-client/src/services/model-configurations.ts index b863787768..bdac5e925d 100644 --- a/packages/client/hmi-client/src/services/model-configurations.ts +++ b/packages/client/hmi-client/src/services/model-configurations.ts @@ -250,7 +250,7 @@ export function getMmtParameters(modelConfiguration, mmt, mmtParams) { default: false, distribution: { type: DistributionType.Constant, - parameters: { value: mmt.parameters?.[childIds[0]]?.value ?? 0 } + parameters: { value: 0 } }, referenceId: id, type: SemanticType.Parameter, From c2c932e3112b0d8e376f91006b3522f1a62362c4 Mon Sep 17 00:00:00 2001 From: Adrian Date: Thu, 14 Nov 2024 15:20:12 -0500 Subject: [PATCH 3/6] set mmt initials --- .../tera-model-config-drilldown.vue | 10 ++++++++ .../src/services/model-configurations.ts | 23 ++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/packages/client/hmi-client/src/components/workflow/ops/model-config/tera-model-config-drilldown.vue b/packages/client/hmi-client/src/components/workflow/ops/model-config/tera-model-config-drilldown.vue index b37e0ca9e5..8482d3dd58 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/model-config/tera-model-config-drilldown.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/model-config/tera-model-config-drilldown.vue @@ -256,6 +256,7 @@ import { getMMT, getModel, getModelConfigurationsForModel, getCalendarSettingsFr import { createModelConfiguration, getArchive, + getMmtInitials, getMissingInputAmount, getMmtParameters, getModelConfigurationById, @@ -633,6 +634,11 @@ const initialize = async (overwriteWithState: boolean = false) => { knobs.value.transientModelConfig = cloneDeep(state.transientModelConfig); } } + + const initials = getMmtInitials(knobs.value.transientModelConfig, mmt.value); + if (initials.length) { + knobs.value.transientModelConfig.initialSemanticList = initials; + } const parameters = getMmtParameters(knobs.value.transientModelConfig, mmt.value, mmtParams.value); if (parameters.length) { knobs.value.transientModelConfig.parameterSemanticList = parameters; @@ -661,6 +667,10 @@ const onSelectConfiguration = async (config: ModelConfiguration) => { pdfViewer.value.goToPage(config.extractionPage); } + const initials = getMmtInitials(knobs.value.transientModelConfig, mmt.value); + if (initials.length) { + knobs.value.transientModelConfig.initialSemanticList = initials; + } const parameters = getMmtParameters(knobs.value.transientModelConfig, mmt.value, mmtParams.value); if (parameters.length) { knobs.value.transientModelConfig.parameterSemanticList = parameters; diff --git a/packages/client/hmi-client/src/services/model-configurations.ts b/packages/client/hmi-client/src/services/model-configurations.ts index bdac5e925d..b3cf0f35b9 100644 --- a/packages/client/hmi-client/src/services/model-configurations.ts +++ b/packages/client/hmi-client/src/services/model-configurations.ts @@ -10,7 +10,7 @@ import type { import { SemanticType } from '@/types/Types'; import { isEmpty, isNaN, isNumber } from 'lodash'; import { pythonInstance } from '@/python/PyodideController'; -import { collapseParameters } from '@/model-representation/mira/mira'; +import { collapseParameters, collapseInitials } from '@/model-representation/mira/mira'; import { DistributionType } from './distribution'; export interface SemanticOtherValues { @@ -246,6 +246,7 @@ export function getMmtParameters(modelConfiguration, mmt, mmtParams) { const childParameters = childIds .map((childId) => parameters.find((p) => p.referenceId === childId)) .filter(Boolean) as ParameterSemantic[]; + const parameter = { default: false, distribution: { @@ -260,3 +261,23 @@ export function getMmtParameters(modelConfiguration, mmt, mmtParams) { return childParameters.length ? { ...childParameters[0] } : parameter; }); } + +export function getMmtInitials(modelConfiguration, mmt) { + const collapsedInitials = collapseInitials(mmt); + const initials = getInitials(modelConfiguration); + return Array.from(collapsedInitials.keys()).map((id) => { + const childTargets = collapsedInitials.get(id) ?? []; + const childInitials = childTargets + .map((childTarget) => initials.find((i) => i.target === childTarget)) + .filter(Boolean) as InitialSemantic[]; + + const initial = { + expression: '', + expressionMathml: '', + target: id, + type: SemanticType.Initial, + source: mmt.annotations.name + }; + return childTargets.length ? { ...childInitials[0] } : initial; + }); +} From 5621e4b8bfada02c9e85193d44b89692334729cb Mon Sep 17 00:00:00 2001 From: Adrian Date: Fri, 15 Nov 2024 19:42:16 -0500 Subject: [PATCH 4/6] suggested change --- .../tera-model-config-drilldown.vue | 42 +++++++++++-------- .../src/services/model-configurations.ts | 42 +++++++------------ 2 files changed, 39 insertions(+), 45 deletions(-) diff --git a/packages/client/hmi-client/src/components/workflow/ops/model-config/tera-model-config-drilldown.vue b/packages/client/hmi-client/src/components/workflow/ops/model-config/tera-model-config-drilldown.vue index 8482d3dd58..4c582a9749 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/model-config/tera-model-config-drilldown.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/model-config/tera-model-config-drilldown.vue @@ -256,9 +256,9 @@ import { getMMT, getModel, getModelConfigurationsForModel, getCalendarSettingsFr import { createModelConfiguration, getArchive, - getMmtInitials, + getModelInitials, getMissingInputAmount, - getMmtParameters, + getModelParameters, getModelConfigurationById, setInitialExpression, setInitialSource, @@ -272,7 +272,11 @@ import { AssetType, Observable } from '@/types/Types'; import type { WorkflowNode } from '@/types/workflow'; import { OperatorStatus } from '@/types/workflow'; import { logger } from '@/utils/logger'; -import { isModelMissingMetadata } from '@/model-representation/service'; +import { + isModelMissingMetadata, + getParameters as getAmrParameters, + getInitials as getAmrInitials +} from '@/model-representation/service'; import Message from 'primevue/message'; import TeraColumnarPanel from '@/components/widgets/tera-columnar-panel.vue'; import TeraSliderPanel from '@/components/widgets/tera-slider-panel.vue'; @@ -635,13 +639,15 @@ const initialize = async (overwriteWithState: boolean = false) => { } } - const initials = getMmtInitials(knobs.value.transientModelConfig, mmt.value); - if (initials.length) { - knobs.value.transientModelConfig.initialSemanticList = initials; - } - const parameters = getMmtParameters(knobs.value.transientModelConfig, mmt.value, mmtParams.value); - if (parameters.length) { - knobs.value.transientModelConfig.parameterSemanticList = parameters; + if (model.value) { + const initials = getModelInitials(knobs.value.transientModelConfig, mmt.value, getAmrInitials(model.value)); + if (initials.length) { + knobs.value.transientModelConfig.initialSemanticList = initials; + } + const parameters = getModelParameters(knobs.value.transientModelConfig, mmt.value, getAmrParameters(model.value)); + if (parameters.length) { + knobs.value.transientModelConfig.parameterSemanticList = parameters; + } } configuredMmt.value = makeConfiguredMMT(mmt.value, knobs.value.transientModelConfig); @@ -667,13 +673,15 @@ const onSelectConfiguration = async (config: ModelConfiguration) => { pdfViewer.value.goToPage(config.extractionPage); } - const initials = getMmtInitials(knobs.value.transientModelConfig, mmt.value); - if (initials.length) { - knobs.value.transientModelConfig.initialSemanticList = initials; - } - const parameters = getMmtParameters(knobs.value.transientModelConfig, mmt.value, mmtParams.value); - if (parameters.length) { - knobs.value.transientModelConfig.parameterSemanticList = parameters; + if (model.value) { + const initials = getModelInitials(knobs.value.transientModelConfig, mmt.value, getAmrInitials(model.value)); + if (initials.length) { + knobs.value.transientModelConfig.initialSemanticList = initials; + } + const parameters = getModelParameters(knobs.value.transientModelConfig, mmt.value, getAmrParameters(model.value)); + if (parameters.length) { + knobs.value.transientModelConfig.parameterSemanticList = parameters; + } } const { transientModelConfig } = knobs.value; // If no changes were made switch right away diff --git a/packages/client/hmi-client/src/services/model-configurations.ts b/packages/client/hmi-client/src/services/model-configurations.ts index b3cf0f35b9..edd3e19cc8 100644 --- a/packages/client/hmi-client/src/services/model-configurations.ts +++ b/packages/client/hmi-client/src/services/model-configurations.ts @@ -8,9 +8,8 @@ import type { ParameterSemantic } from '@/types/Types'; import { SemanticType } from '@/types/Types'; -import { isEmpty, isNaN, isNumber } from 'lodash'; +import { isEmpty, isNaN, isNumber, keyBy } from 'lodash'; import { pythonInstance } from '@/python/PyodideController'; -import { collapseParameters, collapseInitials } from '@/model-representation/mira/mira'; import { DistributionType } from './distribution'; export interface SemanticOtherValues { @@ -238,46 +237,33 @@ export function getMissingInputAmount(modelConfiguration: ModelConfiguration) { return missingInputs; } -export function getMmtParameters(modelConfiguration, mmt, mmtParams) { - const collapsedParameters = collapseParameters(mmt, mmtParams); - const parameters = getParameters(modelConfiguration); - return Array.from(collapsedParameters.keys()).map((id) => { - const childIds = collapsedParameters.get(id) ?? []; - const childParameters = childIds - .map((childId) => parameters.find((p) => p.referenceId === childId)) - .filter(Boolean) as ParameterSemantic[]; - - const parameter = { +export function getModelParameters(modelConfiguration, mmt, amrParameters) { + const configParameters = keyBy(getParameters(modelConfiguration), 'referenceId'); + return amrParameters.map((parameter) => { + if (configParameters[parameter.id]) return { ...configParameters[parameter.id] }; + return { default: false, distribution: { type: DistributionType.Constant, - parameters: { value: 0 } + parameters: { value: NaN } }, - referenceId: id, + referenceId: parameter.id, type: SemanticType.Parameter, source: mmt.annotations.name }; - - return childParameters.length ? { ...childParameters[0] } : parameter; }); } -export function getMmtInitials(modelConfiguration, mmt) { - const collapsedInitials = collapseInitials(mmt); - const initials = getInitials(modelConfiguration); - return Array.from(collapsedInitials.keys()).map((id) => { - const childTargets = collapsedInitials.get(id) ?? []; - const childInitials = childTargets - .map((childTarget) => initials.find((i) => i.target === childTarget)) - .filter(Boolean) as InitialSemantic[]; - - const initial = { +export function getModelInitials(modelConfiguration, mmt, amrInitials) { + const configInitials = keyBy(getInitials(modelConfiguration), 'target'); + return amrInitials.map((initial) => { + if (configInitials[initial.target]) return { ...configInitials[initial.target] }; + return { expression: '', expressionMathml: '', - target: id, + target: initial.target, type: SemanticType.Initial, source: mmt.annotations.name }; - return childTargets.length ? { ...childInitials[0] } : initial; }); } From c40262bef1acd5c437d1ee568dcaa3eda273517c Mon Sep 17 00:00:00 2001 From: Adrian Date: Fri, 15 Nov 2024 19:45:34 -0500 Subject: [PATCH 5/6] suggested changes --- .../tera-model-config-drilldown.vue | 24 +++++++++++++++---- .../src/services/model-configurations.ts | 8 +++---- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/packages/client/hmi-client/src/components/workflow/ops/model-config/tera-model-config-drilldown.vue b/packages/client/hmi-client/src/components/workflow/ops/model-config/tera-model-config-drilldown.vue index 4c582a9749..fd27febcc3 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/model-config/tera-model-config-drilldown.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/model-config/tera-model-config-drilldown.vue @@ -640,11 +640,19 @@ const initialize = async (overwriteWithState: boolean = false) => { } if (model.value) { - const initials = getModelInitials(knobs.value.transientModelConfig, mmt.value, getAmrInitials(model.value)); + const initials = getModelInitials( + knobs.value.transientModelConfig, + mmt.value.annotations.name, + getAmrInitials(model.value) + ); if (initials.length) { knobs.value.transientModelConfig.initialSemanticList = initials; } - const parameters = getModelParameters(knobs.value.transientModelConfig, mmt.value, getAmrParameters(model.value)); + const parameters = getModelParameters( + knobs.value.transientModelConfig, + mmt.value.annotations.name, + getAmrParameters(model.value) + ); if (parameters.length) { knobs.value.transientModelConfig.parameterSemanticList = parameters; } @@ -674,11 +682,19 @@ const onSelectConfiguration = async (config: ModelConfiguration) => { } if (model.value) { - const initials = getModelInitials(knobs.value.transientModelConfig, mmt.value, getAmrInitials(model.value)); + const initials = getModelInitials( + knobs.value.transientModelConfig, + mmt.value.annotations.name, + getAmrInitials(model.value) + ); if (initials.length) { knobs.value.transientModelConfig.initialSemanticList = initials; } - const parameters = getModelParameters(knobs.value.transientModelConfig, mmt.value, getAmrParameters(model.value)); + const parameters = getModelParameters( + knobs.value.transientModelConfig, + mmt.value.annotations.name, + getAmrParameters(model.value) + ); if (parameters.length) { knobs.value.transientModelConfig.parameterSemanticList = parameters; } diff --git a/packages/client/hmi-client/src/services/model-configurations.ts b/packages/client/hmi-client/src/services/model-configurations.ts index edd3e19cc8..51fd9d78a1 100644 --- a/packages/client/hmi-client/src/services/model-configurations.ts +++ b/packages/client/hmi-client/src/services/model-configurations.ts @@ -237,7 +237,7 @@ export function getMissingInputAmount(modelConfiguration: ModelConfiguration) { return missingInputs; } -export function getModelParameters(modelConfiguration, mmt, amrParameters) { +export function getModelParameters(modelConfiguration, source, amrParameters) { const configParameters = keyBy(getParameters(modelConfiguration), 'referenceId'); return amrParameters.map((parameter) => { if (configParameters[parameter.id]) return { ...configParameters[parameter.id] }; @@ -249,12 +249,12 @@ export function getModelParameters(modelConfiguration, mmt, amrParameters) { }, referenceId: parameter.id, type: SemanticType.Parameter, - source: mmt.annotations.name + source }; }); } -export function getModelInitials(modelConfiguration, mmt, amrInitials) { +export function getModelInitials(modelConfiguration, source, amrInitials) { const configInitials = keyBy(getInitials(modelConfiguration), 'target'); return amrInitials.map((initial) => { if (configInitials[initial.target]) return { ...configInitials[initial.target] }; @@ -263,7 +263,7 @@ export function getModelInitials(modelConfiguration, mmt, amrInitials) { expressionMathml: '', target: initial.target, type: SemanticType.Initial, - source: mmt.annotations.name + source }; }); } From fcd8b1fb227e840218121ab8db8cc4629cdb1fe9 Mon Sep 17 00:00:00 2001 From: Adrian Date: Mon, 18 Nov 2024 09:50:03 -0500 Subject: [PATCH 6/6] removed unneeded code --- .../tera-model-config-drilldown.vue | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/packages/client/hmi-client/src/components/workflow/ops/model-config/tera-model-config-drilldown.vue b/packages/client/hmi-client/src/components/workflow/ops/model-config/tera-model-config-drilldown.vue index fd27febcc3..eda816de06 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/model-config/tera-model-config-drilldown.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/model-config/tera-model-config-drilldown.vue @@ -681,24 +681,6 @@ const onSelectConfiguration = async (config: ModelConfiguration) => { pdfViewer.value.goToPage(config.extractionPage); } - if (model.value) { - const initials = getModelInitials( - knobs.value.transientModelConfig, - mmt.value.annotations.name, - getAmrInitials(model.value) - ); - if (initials.length) { - knobs.value.transientModelConfig.initialSemanticList = initials; - } - const parameters = getModelParameters( - knobs.value.transientModelConfig, - mmt.value.annotations.name, - getAmrParameters(model.value) - ); - if (parameters.length) { - knobs.value.transientModelConfig.parameterSemanticList = parameters; - } - } const { transientModelConfig } = knobs.value; // If no changes were made switch right away if (isModelConfigsEqual(originalConfig, transientModelConfig)) {