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: save model compare state #2998

Merged
merged 41 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
e5f4dc9
save model compare state
shawnyama Mar 12, 2024
c4cce0c
Merge branch 'main' into model-compare-state
shawnyama Mar 12, 2024
0bb485d
save code func
shawnyama Mar 12, 2024
fa4fbf7
merge
shawnyama Mar 13, 2024
aa41793
save state
shawnyama Mar 14, 2024
ea144c4
comment
shawnyama Mar 14, 2024
b9a6585
Merge branch 'main' into model-compare-state
shawnyama Mar 14, 2024
4ae5786
ports
shawnyama Mar 14, 2024
fca531b
Merge branch 'model-compare-state' of https://github.com/DARPA-ASKEM/…
shawnyama Mar 14, 2024
57294b0
linter
shawnyama Mar 14, 2024
f4a2872
unused css
shawnyama Mar 14, 2024
f3878fa
reset
shawnyama Mar 14, 2024
0d6a66f
Merge branch 'main' into model-compare-state
shawnyama Mar 14, 2024
596ca88
store image in S3
bigglesandginger Mar 14, 2024
491038d
Merge branch 'model-compare-state' of github.com:DARPA-ASKEM/TERArium…
bigglesandginger Mar 14, 2024
55d91be
rm changes that dont belong here
shawnyama Mar 14, 2024
d526369
more ^
shawnyama Mar 14, 2024
65e2388
Merge branch 'main' into model-compare-state
shawnyama Mar 14, 2024
9013387
uuid tweak
shawnyama Mar 14, 2024
30dddea
save to backend attempt
shawnyama Mar 14, 2024
8dd9609
Merge branch 'main' into model-compare-state
shawnyama Mar 14, 2024
f5c311b
linter
shawnyama Mar 14, 2024
969cfaa
linter
shawnyama Mar 14, 2024
e11c0a6
unwrap Option
bigglesandginger Mar 15, 2024
4c5e154
mime decoder
shawnyama Mar 15, 2024
6e25eb5
Merge branch 'main' into model-compare-state
shawnyama Mar 15, 2024
1cde4ff
Merge branch 'model-compare-state' of https://github.com/DARPA-ASKEM/…
shawnyama Mar 15, 2024
18a7faf
state management and delete image
shawnyama Mar 15, 2024
bf54bd8
Merge branch 'main' into model-compare-state
shawnyama Mar 15, 2024
cfe744b
fix deletion order
shawnyama Mar 15, 2024
bf1bed3
vite config
shawnyama Mar 15, 2024
d5dfb62
rm log
shawnyama Mar 15, 2024
709f368
Merge branch 'main' into model-compare-state
shawnyama Mar 15, 2024
3f152ac
Merge branch 'main' into model-compare-state
YohannParis Mar 15, 2024
0700244
Merge branch 'main' into model-compare-state
shawnyama Mar 18, 2024
d21a9dd
Add the proper path for the images
YohannParis Mar 18, 2024
1f843ef
Update ImageService.java
YohannParis Mar 18, 2024
532a07e
Update application.properties
YohannParis Mar 18, 2024
86abd06
Merge branch 'main' into model-compare-state
shawnyama Mar 18, 2024
93f8e28
address daniel comments
shawnyama Mar 18, 2024
d7042d0
Merge branch 'main' into model-compare-state
shawnyama Mar 18, 2024
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
@@ -1,6 +1,15 @@
import { Operation, WorkflowOperationTypes } from '@/types/workflow';

export interface ModelComparisonOperationState {}
export interface NotebookHistory {
code: string;
timestamp: number;
}

export interface ModelComparisonOperationState {
notebookHistory: NotebookHistory[];
hasCodeRun: boolean;
structuralComparisons: string[];
}
shawnyama marked this conversation as resolved.
Show resolved Hide resolved

export const ModelComparisonOperation: Operation = {
name: WorkflowOperationTypes.MODEL_COMPARISON,
Expand All @@ -14,7 +23,11 @@ export const ModelComparisonOperation: Operation = {
isRunnable: true,
action: () => {},
initState: () => {
const init: ModelComparisonOperationState = {};
const init: ModelComparisonOperationState = {
notebookHistory: [],
hasCodeBeenRun: false,
structuralComparisons: []
};
return init;
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
</template>

<script setup lang="ts">
import { isEmpty } from 'lodash';
import { isEmpty, cloneDeep } from 'lodash';
import TeraDrilldownSection from '@/components/drilldown/tera-drilldown-section.vue';
import TeraDrilldown from '@/components/drilldown/tera-drilldown.vue';
import TeraDrilldownPreview from '@/components/drilldown/tera-drilldown-preview.vue';
Expand Down Expand Up @@ -144,9 +144,9 @@ const sampleAgentQuestions = [
];

const isLoadingStructuralComparisons = ref(false);
const structuralComparisons = ref<string[]>([]);
const structuralComparisons = ref(props.node.state.structuralComparisons);
const llmAnswer = ref('');
const code = ref('');
const code = ref(props.node.state.notebookHistory?.[0]?.code ?? '');
const isKernelReady = ref(false);
const modelsToCompare = ref<Model[]>([]);

Expand Down Expand Up @@ -189,6 +189,29 @@ function formatField(field: string) {
// console.log(gollmQuestion.value);
// }

// FIXME: Copy pasted in 3 locations, could be written cleaner and in a service
const saveCodeToState = (hasCodeRun: boolean) => {
const state = cloneDeep(props.node.state);
state.hasCodeRun = hasCodeRun;

// for now only save the last code executed, may want to save all code executed in the future
const notebookHistoryLength = props.node.state.notebookHistory.length;
const timestamp = Date.now();
if (notebookHistoryLength > 0) {
state.notebookHistory[0] = { code: code.value, timestamp };
} else {
state.notebookHistory.push({ code: code.value, timestamp });
}
return state;
};

function saveState() {
const state = saveCodeToState(code.value, true);
state.structuralComparisons = structuralComparisons.value;
console.log(state);
emit('update-state', state);
}

function runCode() {
const messageContent = {
silent: false,
Expand All @@ -205,6 +228,7 @@ function runCode() {
.register('display_data', (data) => {
structuralComparisons.value.push(`data:image/png;base64,${data.content.data['image/png']}`);
isLoadingStructuralComparisons.value = false;
saveState();
})
.register('error', (data) => {
logger.error(`${data.content.ename}: ${data.content.evalue}`);
Expand Down Expand Up @@ -253,6 +277,7 @@ async function buildJupyterContext() {
}

onMounted(async () => {
console.log(props.node.state);
props.node.inputs.forEach((input) => {
if (input.value) {
addModelForComparison(input.value[0]);
Expand Down
Loading