-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Yohann Paris <github@yohannparis.com>
- Loading branch information
1 parent
d6e2186
commit be739c7
Showing
11 changed files
with
722 additions
and
2 deletions.
There are no files selected for viewing
548 changes: 548 additions & 0 deletions
548
packages/client/hmi-client/src/components/dataset/tera-dataset-jupyter-regridding-panel.vue
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/client/hmi-client/src/workflow/ops/regridding/mod.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { RegriddingOperation as operation } from './regridding-operation'; | ||
import node from './tera-regridding-node.vue'; | ||
import drilldown from './tera-regridding.vue'; | ||
|
||
const name = operation.name; | ||
|
||
export { name, operation, node, drilldown }; |
23 changes: 23 additions & 0 deletions
23
packages/client/hmi-client/src/workflow/ops/regridding/regridding-operation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Operation, WorkflowOperationTypes } from '@/types/workflow'; | ||
|
||
export interface RegriddingState { | ||
datasetId: string | null; | ||
notebookSessionId?: string; | ||
} | ||
|
||
export const RegriddingOperation: Operation = { | ||
name: WorkflowOperationTypes.REGRIDDING, | ||
description: 'Select a dataset', | ||
displayName: 'Transform gridded dataset', | ||
isRunnable: true, | ||
inputs: [{ type: 'datasetId', label: 'Dataset' }], | ||
outputs: [], | ||
action: () => {}, | ||
|
||
initState: () => { | ||
const init: RegriddingState = { | ||
datasetId: null | ||
}; | ||
return init; | ||
} | ||
}; |
36 changes: 36 additions & 0 deletions
36
packages/client/hmi-client/src/workflow/ops/regridding/tera-regridding-node.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<template> | ||
<section> | ||
<tera-operator-placeholder v-if="!node.inputs[0].value" :operation-type="node.operationType"> | ||
Attach one or more resources | ||
</tera-operator-placeholder> | ||
<Button v-else label="Edit" @click="emit('open-drilldown')" severity="secondary" outlined /> | ||
</section> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { watch } from 'vue'; | ||
import { WorkflowNode, WorkflowPortStatus } from '@/types/workflow'; | ||
import Button from 'primevue/button'; | ||
import TeraOperatorPlaceholder from '@/components/operator/tera-operator-placeholder.vue'; | ||
import { RegriddingState } from './regridding-operation'; | ||
const emit = defineEmits(['append-input-port', 'open-drilldown']); | ||
const props = defineProps<{ | ||
node: WorkflowNode<RegriddingState>; | ||
}>(); | ||
watch( | ||
// add another input port when all inputs are connected, we want to add as many datasets as we can | ||
() => props.node.inputs, | ||
() => { | ||
const inputs = props.node.inputs; | ||
if (inputs.every((input) => input.status === WorkflowPortStatus.CONNECTED)) { | ||
emit('append-input-port', { type: 'datasetId', labe: 'Dataset' }); | ||
} | ||
}, | ||
{ deep: true } | ||
); | ||
</script> | ||
|
||
<style scoped></style> |
94 changes: 94 additions & 0 deletions
94
packages/client/hmi-client/src/workflow/ops/regridding/tera-regridding.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<template> | ||
<tera-drilldown :title="node.displayName" @on-close-clicked="emit('close')"> | ||
<template #header-actions> | ||
<tera-operator-annotation | ||
:state="node.state" | ||
@update-state="(state: any) => emit('update-state', state)" | ||
/> | ||
</template> | ||
<div class="background"> | ||
<Suspense> | ||
<tera-dataset-jupyter-regridding-panel | ||
:assets="assets" | ||
:show-kernels="showKernels" | ||
:show-chat-thoughts="showChatThoughts" | ||
@new-dataset-saved="addOutputPort" | ||
:notebook-session="notebookSession" | ||
/> | ||
</Suspense> | ||
</div> | ||
</tera-drilldown> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
// Proxy to use tera-dataset via a workflow context | ||
import { WorkflowNode, WorkflowPortStatus } from '@/types/workflow'; | ||
import TeraDatasetJupyterRegriddingPanel from '@/components/dataset/tera-dataset-jupyter-regridding-panel.vue'; | ||
import { computed, onMounted, ref } from 'vue'; | ||
import { createNotebookSession, getNotebookSessionById } from '@/services/notebook-session'; | ||
import type { NotebookSession } from '@/types/Types'; | ||
import { cloneDeep } from 'lodash'; | ||
import { v4 as uuidv4 } from 'uuid'; | ||
import TeraDrilldown from '@/components/drilldown/tera-drilldown.vue'; | ||
import TeraOperatorAnnotation from '@/components/operator/tera-operator-annotation.vue'; | ||
import { RegriddingState } from './regridding-operation'; | ||
const props = defineProps<{ | ||
node: WorkflowNode<RegriddingState>; | ||
}>(); | ||
const emit = defineEmits(['append-output', 'update-state', 'close']); | ||
const showKernels = ref(<boolean>false); | ||
const showChatThoughts = ref(<boolean>false); | ||
const assets = computed(() => | ||
props.node.inputs | ||
.filter((inputNode) => inputNode.status === WorkflowPortStatus.CONNECTED && inputNode.value) | ||
.map((inputNode) => ({ | ||
type: inputNode.type, | ||
id: inputNode.value![0] | ||
})) | ||
); | ||
const notebookSession = ref(<NotebookSession | undefined>undefined); | ||
onMounted(async () => { | ||
const state = cloneDeep(props.node.state); | ||
let notebookSessionId = props.node.state?.notebookSessionId; | ||
if (!notebookSessionId) { | ||
// create a new notebook session log if it does not exist | ||
const response = await createNotebookSession({ | ||
id: uuidv4(), | ||
name: props.node.id, | ||
description: '', | ||
data: { history: [] } | ||
}); | ||
notebookSessionId = response?.id; | ||
if (notebookSessionId) { | ||
// update the node state with the notebook session id | ||
state.notebookSessionId = notebookSessionId; | ||
emit('update-state', state); | ||
} | ||
} | ||
notebookSession.value = await getNotebookSessionById(notebookSessionId!); | ||
}); | ||
const addOutputPort = (data: any) => { | ||
emit('append-output', { | ||
id: data.id, | ||
label: data.name, | ||
type: 'datasetId', | ||
value: data.id | ||
}); | ||
}; | ||
</script> | ||
|
||
<style scoped> | ||
.background { | ||
background: white; | ||
height: 100%; | ||
overflow-y: auto; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters