Skip to content

Commit

Permalink
fix: parameter unit assignment when adding a template card (#3358)
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnyama authored Apr 17, 2024
1 parent ae51557 commit 443073f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ const buildParameterTable = () => {
type: paramType,
description: param?.description ?? '',
concept: param?.grounding ?? { identifiers: {} },
unit: param?.unit?.expression ?? '',
units: param?.units?.expression ?? '',
value: param,
source: sourceValue,
visibility: false,
Expand Down Expand Up @@ -550,7 +550,7 @@ const buildParameterTable = () => {
type: paramType,
description: param.description ?? '',
concept: param.grounding ?? { identifiers: {} },
unit: param.unit?.expression,
unit: param.units?.expression,
value: param,
source: sourceValue,
visibility: false,
Expand All @@ -571,7 +571,7 @@ const buildParameterTable = () => {
type: paramType,
description: aux.description,
concept: aux.grounding,
unit: aux.unit?.expression,
unit: aux.units?.expression,
value: aux,
source: sourceValue,
visibility: false,
Expand Down
6 changes: 3 additions & 3 deletions packages/client/hmi-client/src/services/model-templating.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
} from '@/types/model-templating';
import { DecomposedModelTemplateTypes } from '@/types/model-templating';
import { KernelSessionManager } from '@/services/jupyter';
import { Model, Initial, ModelUnit } from '@/types/Types';
import { Model, Initial } from '@/types/Types';
import { logger } from '@/utils/logger';
import naturalConversionTemplate from './model-templates/natural-conversion.json';
import naturalProductionTemplate from './model-templates/natural-production.json';
Expand All @@ -29,7 +29,7 @@ interface AddTemplateArguments {
controller_initial_value?: string;
parameter_name?: string;
parameter_value?: number;
parameter_units?: ModelUnit;
parameter_units?: string;
parameter_description?: string;
template_expression?: string;
template_name?: string;
Expand Down Expand Up @@ -252,7 +252,7 @@ export function addDecomposedTemplateInKernel(
if (parameters) {
addTemplateArguments.parameter_name = parameters[0].id;
addTemplateArguments.parameter_value = parameters[0].value;
addTemplateArguments.parameter_units = parameters[0].unit ?? undefined;
addTemplateArguments.parameter_units = parameters[0]?.units?.expression;
addTemplateArguments.parameter_description = parameters[0].description;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/client/hmi-client/src/types/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ export interface ModelParameter {
value?: number;
grounding?: ModelGrounding;
distribution?: ModelDistribution;
unit?: ModelUnit;
units?: ModelUnit;
}

export interface Observable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ public class ModelParameter extends SupportAdditionalProperties implements Seria
private ModelDistribution distribution;

@TSOptional
private ModelUnit unit;
private ModelUnit units;
}

0 comments on commit 443073f

Please sign in to comment.