Skip to content

Commit

Permalink
default preview code comments for dataset transformer (#4813)
Browse files Browse the repository at this point in the history
Co-authored-by: Cole Blanchard <[email protected]>
  • Loading branch information
blanchco and Cole Blanchard authored Sep 17, 2024
1 parent 97d4083 commit 84166fb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
:jupyter-session="jupyterSession"
:kernel-status="kernelStatus"
:language="selectedLanguage"
:default-preview="defaultPreview"
@update-kernel-state="(e) => emit('update-kernel-state', e)"
@update-kernel-status="updateKernelStatus"
@new-dataset-saved="onNewDatasetSaved"
Expand Down Expand Up @@ -155,10 +156,21 @@ const jupyterSession: SessionContext = await newSession('beaker_kernel', 'Beaker
const selectedKernel = ref();
const runningSessions = ref<any[]>([]);
const defaultPreview = computed(() => {
let code = '';
props.assets.forEach((asset, index) => {
code += `#d${index + 1} = ${asset.name}\n`;
});
// add first dataset to the code
code += 'd1';
return code;
});
const confirm = useConfirm();
const props = defineProps<{
assets: { id: string; type: string }[];
assets: { id: string; type: string; name: string }[];
showKernels: boolean;
showChatThoughts: boolean;
notebookSession?: NotebookSession;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
:is-executing-code="isExecutingCode"
:show-chat-thoughts="props.showChatThoughts"
:auto-expand-preview="autoExpandPreview"
:default-preview="defaultPreview"
:language="language"
@preview-selected="previewSelected"
@delete-message="handleDeleteMessage"
@delete-prompt="handleDeletePrompt"
@re-run-prompt="handleRerunPrompt"
Expand Down Expand Up @@ -85,10 +83,9 @@ const props = defineProps<{
kernelStatus: String;
autoExpandPreview?: boolean;
notebookSession?: NotebookSession;
defaultPreview?: string;
}>();
const defaultPreview = ref('d1');
const iopubMessageHandler = (_session, message) => {
if (message.header.msg_type === 'status') {
const newState: KernelState = KernelState[KernelState[message.content.execution_state]];
Expand Down Expand Up @@ -162,10 +159,6 @@ const selectNextCell = () => {
scrollToCell(notebookCell);
};
const previewSelected = (selection) => {
defaultPreview.value = selection;
};
props.jupyterSession.iopubMessage.connect(iopubMessageHandler);
const submitQuery = (inputStr: string | undefined) => {
Expand Down Expand Up @@ -245,7 +238,7 @@ const addCodeCell = (isDefaultCell: boolean = false, isNextCell: boolean = true)
metadata: {},
content: {
language: 'python',
code: isDefaultCell ? defaultPreview.value : ''
code: isDefaultCell ? props.defaultPreview : ''
},
channel: 'iopub'
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import TeraDrilldown from '@/components/drilldown/tera-drilldown.vue';
import Button from 'primevue/button';
import Dropdown from 'primevue/dropdown';
import { useProjects } from '@/composables/project';
import { DatasetTransformerState } from './dataset-transformer-operation';
const props = defineProps<{
Expand All @@ -64,7 +65,8 @@ const assets = computed(() =>
.filter((inputNode) => inputNode.status === WorkflowPortStatus.CONNECTED && inputNode.value)
.map((inputNode) => ({
type: inputNode.type,
id: inputNode.value![0]
id: inputNode.value![0],
name: useProjects().getAssetName(inputNode.value![0])
}))
);
Expand Down

0 comments on commit 84166fb

Please sign in to comment.