From 18e07a781d453b867f325ae6086abe406767fd11 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Wed, 13 Dec 2023 08:14:34 +0100 Subject: [PATCH] fix: improve nested flow status viewer --- .../components/FlowStatusViewerInner.svelte | 54 +++++++++---------- .../src/lib/components/FlowTimeline.svelte | 12 ++--- python-client/wmill/wmill/client.py | 2 +- 3 files changed, 31 insertions(+), 37 deletions(-) diff --git a/frontend/src/lib/components/FlowStatusViewerInner.svelte b/frontend/src/lib/components/FlowStatusViewerInner.svelte index c346e7ec6f..d631342e3f 100644 --- a/frontend/src/lib/components/FlowStatusViewerInner.svelte +++ b/frontend/src/lib/components/FlowStatusViewerInner.svelte @@ -57,7 +57,6 @@ export let selectedNode: string | undefined = undefined - export let nestedFlow: string | undefined = undefined export let globalModuleStates: Writable>[] export let globalDurationStatuses: Writable>[] @@ -104,10 +103,10 @@ } function initializeByJob(modId: string) { - let prefixed = prefixNF(modId) - if ($localDurationStatuses[prefixed] == undefined) { - $localDurationStatuses[prefixed] = { byJob: {} } + if ($localDurationStatuses[modId] == undefined) { + $localDurationStatuses[modId] = { byJob: {} } } + let prefixed = modId globalDurationStatuses.forEach((x) => x.update((x) => { if (x[prefixed] == undefined) { @@ -118,19 +117,17 @@ ) } - function prefixNF(s: string | undefined) { - return nestedFlow ? `${nestedFlow}-${s ?? ''}` : s ?? '' - } if (flowJobIds) { let common = { iteration_from: Math.max(flowJobIds.flowJobs.length - 20, 0), iteration_total: flowJobIds?.length } - let prefixed = prefixNF(flowJobIds?.moduleId ?? '') - $localDurationStatuses[prefixed] = { - ...($localDurationStatuses[prefixed] ?? { byJob: {} }), + let modId = flowJobIds?.moduleId ?? '' + $localDurationStatuses[modId] = { + ...($localDurationStatuses[modId] ?? { byJob: {} }), ...common } + let prefixed = modId globalDurationStatuses.forEach((x) => x.update((x) => { x[prefixed] = { ...(x[prefixed] ?? { byJob: {} }), ...common } @@ -272,7 +269,7 @@ started_at, parent_module: mod['parent_module'] }) - setDurationStatusByJob(prefixNF(mod.id), job.id, { + setDurationStatusByJob(mod.id, job.id, { created_at: job.created_at ? new Date(job.created_at).getTime() : undefined, started_at }) @@ -290,7 +287,7 @@ iteration_total: mod.iterator?.itered?.length // retries: $flowStateStore?.raw_flow }) - setDurationStatusByJob(prefixNF(mod.id), job.id, { + setDurationStatusByJob(mod.id, job.id, { created_at: job.created_at ? new Date(job.created_at).getTime() : undefined, started_at, duration_ms: job['duration_ms'] @@ -341,7 +338,7 @@ duration_ms: undefined }) - setDurationStatusByJob(prefixNF(modId), job_id, { + setDurationStatusByJob(modId, job_id, { created_at, started_at }) @@ -358,7 +355,7 @@ duration_ms: undefined, isListJob: true }) - setDurationStatusByJob(prefixNF(modId), job_id, { + setDurationStatusByJob(modId, job_id, { created_at, started_at, duration_ms: jobLoaded.duration_ms @@ -380,10 +377,10 @@ initializeByJob(id) setDurationStatusByJob( - prefixNF(id), + id, job_id, - $localDurationStatuses[prefixNF(modId)].byJob[job_id] + $localDurationStatuses[modId].byJob[job_id] ) } } @@ -405,7 +402,7 @@ {#if isListJob} {@const lenToAdd = Math.min( 20, - $localDurationStatuses[prefixNF(flowJobIds?.moduleId ?? '')]?.iteration_from ?? 0 + $localDurationStatuses[flowJobIds?.moduleId ?? '']?.iteration_from ?? 0 )} {#if (flowJobIds?.flowJobs.length ?? 0) > 20 && lenToAdd > 0} @@ -413,7 +410,7 @@ For performance reasons, only the last 20 items are shown by default

{/if} - {#each (flowJobIds?.flowJobs.length ?? 0) > 20 ? flowJobIds?.flowJobs?.slice($localDurationStatuses[prefixNF(flowJobIds?.moduleId ?? '')]?.iteration_from ?? 0) ?? [] : flowJobIds?.flowJobs ?? [] as loopJobId, j (loopJobId)} + {#each (flowJobIds?.flowJobs.length ?? 0) > 20 ? flowJobIds?.flowJobs?.slice($localDurationStatuses[flowJobIds?.moduleId ?? '']?.iteration_from ?? 0) ?? [] : flowJobIds?.flowJobs ?? [] as loopJobId, j (loopJobId)} {#if render} {/if}
-
{key}
+
{k}
{#if min && total}
- {#each items?.[key] ?? [] as b} + {#each items?.[k] ?? [] as b} {@const waitingLen = b?.created_at ? b.started_at ? b.started_at - b?.created_at diff --git a/python-client/wmill/wmill/client.py b/python-client/wmill/wmill/client.py index 6d9045e4b7..6f5825d4ac 100644 --- a/python-client/wmill/wmill/client.py +++ b/python-client/wmill/wmill/client.py @@ -272,7 +272,7 @@ class Windmill: self, path: str, none_if_undefined: bool = False, - ) -> str | dict | None: + ) -> dict | None: """Get resource from Windmill""" try: return self.get(f"/w/{self.workspace}/resources/get_value_interpolated/{path}").json()