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

ability allow only 1 unique asset id in an input #5447

Merged
merged 5 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -59,7 +59,7 @@ export const CalibrateEnsembleCiemssOperation: Operation = {
imageUrl: calibrateEnsembleCiemss,
inputs: [
{ type: 'datasetId', label: 'Dataset' },
{ type: 'modelConfigId', label: 'Model configuration' }
{ type: 'modelConfigId', label: 'Model configuration', unique: true }
],
outputs: [{ type: 'simulationId' }],
isRunnable: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ watch(
(input) => input.status === WorkflowPortStatus.CONNECTED || input.type !== 'modelConfigId'
)
) {
emit('append-input-port', { type: 'modelConfigId', label: 'Model configuration' });
emit('append-input-port', { type: 'modelConfigId', label: 'Model configuration', unique: true });
}
},
{ deep: true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,13 +343,17 @@ const saveWorkflowHandler = () => {
saveWorkflowDebounced();
};

function appendInputPort(node: WorkflowNode<any>, port: { type: string; label?: string; value: any }) {
function appendInputPort(
node: WorkflowNode<any>,
port: { type: string; label?: string; value: any; unique?: boolean }
) {
node.inputs.push({
id: uuidv4(),
type: port.type,
label: port.label,
isOptional: false,
status: WorkflowPortStatus.NOT_CONNECTED
status: WorkflowPortStatus.NOT_CONNECTED,
unique: port.unique
});
}

Expand Down
8 changes: 7 additions & 1 deletion packages/client/hmi-client/src/services/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ export class WorkflowWrapper {
label: port.label,
status: WorkflowPortStatus.NOT_CONNECTED,
value: null,
isOptional: port.isOptional ?? false
isOptional: port.isOptional ?? false,
unique: port.unique
})),

outputs: op.outputs.map((port) => ({
Expand Down Expand Up @@ -322,6 +323,11 @@ export class WorkflowWrapper {
return;
}

// check if the port value is unique, if so, we should not connect the incoming edge
if (targetNode.inputs.some((input) => input.unique && input.value?.[0] === sourceOutputPort.value?.[0])) {
return;
}
blanchco marked this conversation as resolved.
Show resolved Hide resolved

// Transfer data value/reference
targetInputPort.label = sourceOutputPort.label;
if (outputTypes.length > 1) {
Expand Down
2 changes: 2 additions & 0 deletions packages/client/hmi-client/src/types/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export interface OperationData {
type: string;
label?: string;
isOptional?: boolean;
unique?: boolean;
}

// Defines a function: eg: model, simulate, calibrate
Expand Down Expand Up @@ -72,6 +73,7 @@ export interface WorkflowPort {
label?: string;
value?: any[] | null;
isOptional: boolean;
unique?: boolean;
}

// Operator Output needs more information than a standard operator port.
Expand Down