From e73821398d354741f55162851e8cd7ea43f58dab Mon Sep 17 00:00:00 2001 From: Jordan Jensen Date: Thu, 2 Nov 2023 15:02:43 -0700 Subject: [PATCH 1/5] Improve typing for Python Status event --- web/src/api/types/events.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/web/src/api/types/events.ts b/web/src/api/types/events.ts index a38ac1f69..000db7ff3 100644 --- a/web/src/api/types/events.ts +++ b/web/src/api/types/events.ts @@ -464,10 +464,21 @@ export function isPublishRestorePythonEnvProgress(arg: Events): return arg.type === 'publish/restorePythonEnv/progress'; } +type packageRuntime = 'r' | 'python'; +type packageStatus = 'download+install' | 'download' | 'install'; + export interface PublishRestorePythonEnvStatus extends EventStreamMessage { type: 'publish/restorePythonEnv/status', - // structured data not guaranteed, use selective or generic queries - // from data map + data: { + level: 'INFO', + localId: string, + message: string, + name: string, + runtime: packageRuntime, + source: 'serverp.log', + status: packageStatus, + version: string + } } export type OnPublishRestorePythonEnvStatusCallback = ( msg: PublishRestorePythonEnvStatus From 26bb032eeb887d79cc55478216de28be265c4ca7 Mon Sep 17 00:00:00 2001 From: Jordan Jensen Date: Thu, 2 Nov 2023 15:15:23 -0700 Subject: [PATCH 2/5] Add optional caption prop to PublishStep --- web/src/components/publishProcess/PublishStep.vue | 2 ++ 1 file changed, 2 insertions(+) diff --git a/web/src/components/publishProcess/PublishStep.vue b/web/src/components/publishProcess/PublishStep.vue index 6e56d3c89..6059e34d7 100644 --- a/web/src/components/publishProcess/PublishStep.vue +++ b/web/src/components/publishProcess/PublishStep.vue @@ -4,6 +4,7 @@ , required: false, default: () => [] }, From 809b6607263cca98767054ad54ecd02a9c6d6c0b Mon Sep 17 00:00:00 2001 From: Jordan Jensen Date: Thu, 2 Nov 2023 15:15:38 -0700 Subject: [PATCH 3/5] Set caption based on python env status event --- .../steps/RestorePythonEnvironment.vue | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/web/src/components/publishProcess/steps/RestorePythonEnvironment.vue b/web/src/components/publishProcess/steps/RestorePythonEnvironment.vue index 9f14b0841..62f25c1b4 100644 --- a/web/src/components/publishProcess/steps/RestorePythonEnvironment.vue +++ b/web/src/components/publishProcess/steps/RestorePythonEnvironment.vue @@ -8,6 +8,7 @@ summary="Installing the dependent python packages on the server in order to reproduce your runtime environment." :done="done" :messages="messages" + :caption="caption" /> @@ -27,6 +28,7 @@ const $eventStream = useEventStream(); const done = ref(false); const messages = ref([]); +const caption = ref(); const startCb = $eventStream.addEventMonitorCallback('publish/restorePythonEnv/start', (msg) => { messages.value.push(msg); @@ -35,11 +37,29 @@ const startCb = $eventStream.addEventMonitorCallback('publish/restorePythonEnv/s const logCb = $eventStream.addEventMonitorCallback('publish/restorePythonEnv/log', (msg) => { messages.value.push(msg); }); -const progressCb = $eventStream.addEventMonitorCallback('publish/restorePythonEnv/progress', (msg) => { - messages.value.push(msg); +const statusCb = $eventStream.addEventMonitorCallback('publish/restorePythonEnv/status', (msg) => { + let newCaption: string; + console.log('This is a status msg', msg); + switch (msg.data.status) { + case 'download+install': + newCaption = `Downloading and installing package: `; + break; + case 'download': + newCaption = `Downloading package: `; + break; + case 'install': + newCaption = `Installing package: `; + break; + } + newCaption += msg.data.name; + if (msg.data.version) { + newCaption += ` (${msg.data.version})`; + } + caption.value = newCaption; }); const successCb = $eventStream.addEventMonitorCallback('publish/restorePythonEnv/success', (msg) => { messages.value.push(msg); + caption.value = undefined; done.value = true; emit('start'); }); @@ -50,7 +70,7 @@ const failureCb = $eventStream.addEventMonitorCallback('publish/restorePythonEnv onBeforeUnmount(() => { $eventStream.delEventFilterCallback(startCb); $eventStream.delEventFilterCallback(logCb); - $eventStream.delEventFilterCallback(progressCb); + $eventStream.delEventFilterCallback(statusCb); $eventStream.delEventFilterCallback(successCb); $eventStream.delEventFilterCallback(failureCb); }); From 22d669f906da8313b32fbf2281de99e0308c5c42 Mon Sep 17 00:00:00 2001 From: Jordan Jensen Date: Thu, 2 Nov 2023 15:17:14 -0700 Subject: [PATCH 4/5] Remove unncessary console.log --- .../components/publishProcess/steps/RestorePythonEnvironment.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/web/src/components/publishProcess/steps/RestorePythonEnvironment.vue b/web/src/components/publishProcess/steps/RestorePythonEnvironment.vue index 62f25c1b4..0c5495d27 100644 --- a/web/src/components/publishProcess/steps/RestorePythonEnvironment.vue +++ b/web/src/components/publishProcess/steps/RestorePythonEnvironment.vue @@ -39,7 +39,6 @@ const logCb = $eventStream.addEventMonitorCallback('publish/restorePythonEnv/log }); const statusCb = $eventStream.addEventMonitorCallback('publish/restorePythonEnv/status', (msg) => { let newCaption: string; - console.log('This is a status msg', msg); switch (msg.data.status) { case 'download+install': newCaption = `Downloading and installing package: `; From 75ae6619699326201a344b57322b06ba830b59f0 Mon Sep 17 00:00:00 2001 From: Jordan Jensen Date: Thu, 2 Nov 2023 15:18:25 -0700 Subject: [PATCH 5/5] Destructure msg.data for readability --- .../publishProcess/steps/RestorePythonEnvironment.vue | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/web/src/components/publishProcess/steps/RestorePythonEnvironment.vue b/web/src/components/publishProcess/steps/RestorePythonEnvironment.vue index 0c5495d27..5a463a928 100644 --- a/web/src/components/publishProcess/steps/RestorePythonEnvironment.vue +++ b/web/src/components/publishProcess/steps/RestorePythonEnvironment.vue @@ -39,7 +39,9 @@ const logCb = $eventStream.addEventMonitorCallback('publish/restorePythonEnv/log }); const statusCb = $eventStream.addEventMonitorCallback('publish/restorePythonEnv/status', (msg) => { let newCaption: string; - switch (msg.data.status) { + + const { status: packageStatus, name: packageName, version } = msg.data; + switch (packageStatus) { case 'download+install': newCaption = `Downloading and installing package: `; break; @@ -50,9 +52,9 @@ const statusCb = $eventStream.addEventMonitorCallback('publish/restorePythonEnv/ newCaption = `Installing package: `; break; } - newCaption += msg.data.name; - if (msg.data.version) { - newCaption += ` (${msg.data.version})`; + newCaption += packageName; + if (version) { + newCaption += ` (${version})`; } caption.value = newCaption; });