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

model config state not stored on outputs #4670

Merged
merged 5 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -188,8 +188,8 @@

<script setup lang="ts">
import '@/ace-config';
import { ComponentPublicInstance, computed, nextTick, onUnmounted, ref, watch } from 'vue';
import { cloneDeep, debounce, isEmpty, orderBy } from 'lodash';
import { ComponentPublicInstance, computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
import { cloneDeep, debounce, isEmpty, orderBy, omit } from 'lodash';
import Accordion from 'primevue/accordion';
import AccordionTab from 'primevue/accordiontab';
import Button from 'primevue/button';
Expand Down Expand Up @@ -527,27 +527,25 @@ const createConfiguration = async () => {
}

const state = cloneDeep(props.node.state);
state.transientModelConfig = data;
useToastService().success('', 'Created model configuration');
emit('append-output', {
type: ModelConfigOperation.outputs[0].type,
label: data.name,
value: data.id,
isSelected: false,
state
state: omit(state, ['transientModelConfig'])
});
};

const onSaveAsModelConfiguration = (data: ModelConfiguration) => {
useToastService().success('', 'Created model configuration');
const state = cloneDeep(props.node.state);
state.transientModelConfig = data;
emit('append-output', {
type: ModelConfigOperation.outputs[0].type,
label: data.name,
value: data.id,
isSelected: false,
state
state: omit(state, ['transientModelConfig'])
});
showSaveModal.value = false;
};
Expand All @@ -572,7 +570,7 @@ const fetchConfigurations = async (modelId: string) => {
};

// Fill the form with the config data
const initialize = async () => {
const initialize = async (overwriteWithState: boolean = false) => {
const state = props.node.state;
const modelId = props.node.inputs[0].value?.[0];
if (!modelId) return;
Expand All @@ -590,9 +588,7 @@ const initialize = async () => {
applyConfigValues(suggestedConfigurationContext.value.tableData[0]);
} else {
originalConfig.value = await getModelConfigurationById(selectedConfigId.value);

// FIXME: Bug sept-03, state.transientModelConfig may not be saved properly before this date
if (state.transientModelConfig.id !== originalConfig.value.id) {
if (!overwriteWithState) {
knobs.value.transientModelConfig = cloneDeep(originalConfig.value);
} else {
knobs.value.transientModelConfig = cloneDeep(state.transientModelConfig);
mwdchang marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -650,15 +646,12 @@ const applyConfigValues = (config: ModelConfiguration) => {
// If the output does not already exist
else {
const state = cloneDeep(props.node.state);
state.transientModelConfig = config;

// Append this config to the output.
emit('append-output', {
type: ModelConfigOperation.outputs[0].type,
label: config.name,
value: config.id,
isSelected: false,
state
state: omit(state, ['transientModelConfig'])
});
}
logger.success(`Configuration applied ${config.name}`);
Expand Down Expand Up @@ -718,15 +711,22 @@ watch(
{ deep: true }
);

onMounted(() => {
// setting as true will overwrite the model config with the current state value
if (props.node.active) {
selectedOutputId.value = props.node.active;
initialize(true);
}
});

watch(
() => props.node.active,
() => {
if (props.node.active) {
selectedOutputId.value = props.node.active;
initialize();
}
},
{ immediate: true }
}
);

onUnmounted(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
</template>

<script setup lang="ts">
import { cloneDeep } from 'lodash';
import { computed, ref, watch } from 'vue';
import { cloneDeep, omit } from 'lodash';
import { computed, watch, ref } from 'vue';
import { WorkflowNode, WorkflowPortStatus } from '@/types/workflow';
import Button from 'primevue/button';
import TeraProgressSpinner from '@/components/widgets/tera-progress-spinner.vue';
Expand Down Expand Up @@ -77,7 +77,7 @@ watch(
label: config.name,
value: config.id,
isSelected: false,
state
state: omit(state, ['transientModelConfig'])
});
}
} else {
Expand Down
Loading