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

feat(funman): show model config in op and make config the output #5078

Merged
merged 19 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ $accordionHeaderTextActiveHoverColor: $textColor !default;
$accordionContentBorder: 0 none !default;
$accordionContentBg: #ffffff !default;
$accordionContentTextColor: $textColor !default;
$accordionContentPadding: 0.5rem 0.5rem 2rem !default;
$accordionContentPadding: 0.5rem 0.5rem 0.5rem !default;

//tabview
$tabviewNavBorder: solid rgba(0, 0, 0, .12) !default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</div>
<span v-if="description" class="description">{{ description }}</span>
</header>
<template v-if="isEmpty(modelConfiguration.inferredParameterList)">
<template v-if="isEmpty(modelConfiguration.inferredParameterList) && !featureConfig?.isPreview">
<main>
<span class="expression">
<tera-input-text
Expand Down Expand Up @@ -67,12 +67,14 @@ import Button from 'primevue/button';
import { getInitialDescription, getInitialName, getInitialUnits, getStates } from '@/model-representation/service';
import { getCurieFromGroundingIdentifier, getNameOfCurieCached } from '@/services/concept';
import { stringToLatexExpression } from '@/services/model';
import type { FeatureConfig } from '@/types/common';

const props = defineProps<{
model: Model;
initialId: string;
modelConfiguration: ModelConfiguration;
modelConfigurations: ModelConfiguration[];
featureConfig?: FeatureConfig;
}>();

const otherValueList = computed(() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
:model-configuration="modelConfiguration"
:modelConfigurations="modelConfigurations"
:initial-id="target"
:feature-config="featureConfig"
@update-expression="emit('update-expression', $event)"
@update-source="emit('update-source', $event)"
/>
Expand All @@ -42,6 +43,7 @@
:model-configuration="modelConfiguration"
:modelConfigurations="modelConfigurations"
:initial-id="baseInitial"
:feature-config="featureConfig"
@update-expression="emit('update-expression', $event)"
@update-source="emit('update-source', $event)"
/>
Expand All @@ -50,7 +52,6 @@
</ul>
</AccordionTab>
</Accordion>

<tera-stratified-matrix-modal
v-if="matrixModalId && isStratified"
:id="matrixModalId"
Expand All @@ -75,6 +76,7 @@ import AccordionTab from 'primevue/accordiontab';
import Button from 'primevue/button';
import Divider from 'primevue/divider';
import TeraInputText from '@/components/widgets/tera-input-text.vue';
import type { FeatureConfig } from '@/types/common';
import TeraStratifiedMatrixModal from './model-configurations/tera-stratified-matrix-modal.vue';
import TeraInitialEntry from './tera-initial-entry.vue';

Expand All @@ -84,6 +86,7 @@ const props = defineProps<{
model: Model;
mmt: MiraModel;
mmtParams: MiraTemplateParams;
featureConfig?: FeatureConfig;
}>();

const emit = defineEmits(['update-expression', 'update-source']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<label>STDDEV</label> {{ displayNumber(inferredDistribution?.parameters?.stddev.toString()) }}
</span>
</div>
<template v-else>
<template v-else-if="!featureConfig?.isPreview">
<main>
<span class="flex gap-2">
<Dropdown
Expand Down Expand Up @@ -93,6 +93,26 @@
/>
</footer>
</template>
<span class="flex gap-4" v-else>
<template v-if="getParameterDistribution(modelConfiguration, parameterId).type === DistributionType.Constant">
<span><label>Type</label> {{ DistributionTypeLabel.Constant }}</span>
<span>
<label>Value</label>
{{ getParameterDistribution(modelConfiguration, parameterId).parameters.value }}
</span>
</template>
<template v-else-if="getParameterDistribution(modelConfiguration, parameterId).type === DistributionType.Uniform">
<span><label>Type</label> {{ DistributionTypeLabel.StandardUniform1 }}</span>
<span>
<label>Min</label>
{{ getParameterDistribution(modelConfiguration, parameterId).parameters.minimum }}
</span>
<span>
<label>Max</label>
{{ getParameterDistribution(modelConfiguration, parameterId).parameters.maximum }}
</span>
shawnyama marked this conversation as resolved.
Show resolved Hide resolved
</template>
</span>
</div>
<tera-parameter-other-value-modal
v-if="showOtherConfigValueModal"
Expand All @@ -113,17 +133,19 @@ import TeraInputText from '@/components/widgets/tera-input-text.vue';
import TeraInputNumber from '@/components/widgets/tera-input-number.vue';
import Button from 'primevue/button';
import Dropdown from 'primevue/dropdown';
import { DistributionType, distributionTypeOptions } from '@/services/distribution';
import { DistributionType, DistributionTypeLabel, distributionTypeOptions } from '@/services/distribution';
import { getParameter } from '@/model-representation/service';
import TeraParameterOtherValueModal from '@/components/model/petrinet/tera-parameter-other-value-modal.vue';
import { displayNumber } from '@/utils/number';
import { getCurieFromGroundingIdentifier, getNameOfCurieCached } from '@/services/concept';
import type { FeatureConfig } from '@/types/common';

const props = defineProps<{
model: Model;
modelConfiguration: ModelConfiguration;
modelConfigurations: ModelConfiguration[];
parameterId: string;
featureConfig?: FeatureConfig;
}>();

const emit = defineEmits(['update-parameter', 'update-source']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Parameters<span class="artifact-amount">({{ numParameters }})</span>
</span>
<Button
v-if="!isAddingUncertainty"
v-if="!isAddingUncertainty && !featureConfig?.isPreview"
label="Add uncertainty"
outlined
severity="secondary"
Expand Down Expand Up @@ -69,6 +69,7 @@
:model-configuration="props.modelConfiguration"
:model-configurations="props.modelConfigurations"
:parameter-id="referenceId"
:featureConfig="featureConfig"
@update-parameter="emit('update-parameters', [$event])"
@update-source="emit('update-source', $event)"
/>
Expand Down Expand Up @@ -96,6 +97,7 @@
:model-configuration="modelConfiguration"
:modelConfigurations="modelConfigurations"
:parameter-id="baseParameter"
:featureConfig="featureConfig"
@update-parameter="emit('update-parameters', [$event])"
@update-source="emit('update-source', $event)"
/>
Expand Down Expand Up @@ -142,6 +144,8 @@ import InputNumber from 'primevue/inputnumber';
import Dropdown from 'primevue/dropdown';
import Checkbox from 'primevue/checkbox';
import TeraInputText from '@/components/widgets/tera-input-text.vue';
import Divider from 'primevue/divider';
YohannParis marked this conversation as resolved.
Show resolved Hide resolved
import type { FeatureConfig } from '@/types/common';
import TeraParameterEntry from './tera-parameter-entry.vue';
import TeraStratifiedMatrixModal from './model-configurations/tera-stratified-matrix-modal.vue';

Expand All @@ -151,6 +155,7 @@ const props = defineProps<{
modelConfigurations: ModelConfiguration[];
mmt: MiraModel;
mmtParams: MiraTemplateParams;
featureConfig?: FeatureConfig;
}>();

const emit = defineEmits(['update-parameters', 'update-source']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ export interface FunmanOperationState extends BaseState {
numSteps: number;
tolerance: number;
inProgressId: string;
runId: string;
compartmentalConstraint: CompartmentalConstraint;
constraintGroups: ConstraintGroup[];
requestParameters: RequestParameter[];

// selected state in ouptut
trajectoryState?: string;
}
Expand All @@ -64,7 +64,7 @@ export const FunmanOperation: Operation = {
{ type: 'modelConfigId', label: 'Model configuration' },
{ type: 'datasetId', label: 'Dataset', isOptional: true }
],
outputs: [{ type: 'funmanQueryId' }],
outputs: [{ type: 'modelConfigId', label: 'Model configuration' }],
isRunnable: true,
action: () => {},
initState: () => {
Expand All @@ -75,7 +75,8 @@ export const FunmanOperation: Operation = {
compartmentalConstraint: { name: 'Compartmental constraint', isActive: true },
constraintGroups: [],
requestParameters: [],
inProgressId: ''
inProgressId: '',
runId: ''
};
return init;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@
<tera-progress-spinner v-if="showSpinner" :font-size="2" is-centered style="height: 100%" />
<template v-else>
<tera-funman-output
v-if="activeOutput"
:fun-model-id="activeOutput.value?.[0]"
v-if="!isEmpty(node.state.runId)"
:run-id="node.state.runId"
:trajectoryState="node.state.trajectoryState"
@update:trajectoryState="updateTrajectorystate"
/>
Expand All @@ -156,7 +156,7 @@
</template>

<script setup lang="ts">
import _, { floor } from 'lodash';
import _, { floor, isEmpty } from 'lodash';
import { computed, ref, watch } from 'vue';
import Button from 'primevue/button';
import TeraInputText from '@/components/widgets/tera-input-text.vue';
Expand Down Expand Up @@ -197,7 +197,7 @@ const props = defineProps<{
node: WorkflowNode<FunmanOperationState>;
}>();

const emit = defineEmits(['append-output', 'select-output', 'update-state', 'close']);
const emit = defineEmits(['select-output', 'update-state', 'close']);

interface BasicKnobs {
tolerance: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ import { WorkflowNode } from '@/types/workflow';
import { FunmanOperationState, FunmanOperation } from '@/components/workflow/ops/funman/funman-operation';
import Button from 'primevue/button';
import { Poller, PollerState } from '@/api/api';
import { pollAction } from '@/services/models/simulation-service';
import { pollAction, getRunResult } from '@/services/models/simulation-service';
import { nodeOutputLabel } from '@/components/workflow/util';
import { logger } from '@/utils/logger';

const emit = defineEmits(['open-drilldown', 'append-output', 'update-state']);

Expand All @@ -34,15 +35,22 @@ const inProgressId = computed(() => props.node.state.inProgressId);
const poller = new Poller();

const addOutputPorts = async (runId: string) => {
const portLabel = props.node.inputs[0].label;
// The validated configuration id is set as the output value
const rawFunmanResult = await getRunResult(runId, 'validation.json');
if (!rawFunmanResult) {
logger.error('Failed to fetch funman result');
return;
}
const validatedConfiguration = JSON.parse(rawFunmanResult).modelConfiguration;

const outState = _.cloneDeep(props.node.state);
outState.inProgressId = '';
outState.runId = runId;

emit('append-output', {
label: nodeOutputLabel(props.node, `${portLabel} Result`),
label: nodeOutputLabel(props.node, `${validatedConfiguration.name} Result`),
type: FunmanOperation.outputs[0].type,
value: runId,
value: validatedConfiguration.id,
state: outState
});
};
Expand Down Expand Up @@ -85,5 +93,3 @@ watch(
{ immediate: true }
);
</script>

<style scoped></style>
Loading
Loading