Skip to content

Commit a5071c7

Browse files
committed
More fixes to job status
1 parent e64dd62 commit a5071c7

File tree

1 file changed

+9
-4
lines changed
  • src/routes/v2/projects/[projectId]/workflows/[workflowId]

1 file changed

+9
-4
lines changed

src/routes/v2/projects/[projectId]/workflows/[workflowId]/+page.svelte

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -500,11 +500,11 @@
500500
credentials: 'include'
501501
}
502502
);
503-
const receivedStatuses = await statusResponse.json();
504503
if (!statusResponse.ok) {
505-
console.error('Error retrieving images status', receivedStatuses);
504+
console.error('Error retrieving images status');
506505
return;
507506
}
507+
const receivedStatuses = await statusResponse.json();
508508
const jobHasError = selectedSubmittedJob?.status === 'failed';
509509
statuses = Object.fromEntries(Object.entries(receivedStatuses).filter(([, v]) => v !== null));
510510
if (selectedSubmittedJob && Object.keys(statuses).length === 0) {
@@ -515,7 +515,12 @@
515515
const submitted = Object.values(statuses).filter((s) => s.status === 'submitted');
516516
if (submitted.length > 0 || selectedSubmittedJob?.status === 'submitted') {
517517
window.clearTimeout(statusWatcherTimer);
518-
statusWatcherTimer = window.setTimeout(loadJobsStatus, updateJobsInterval);
518+
// if there are no null statuses and no submitted statuses the job is completed,
519+
// so we can reload the latest job immediately, otherwise wait default timeout
520+
const allCompleted =
521+
Object.entries(receivedStatuses).length === Object.values(statuses).length &&
522+
submitted.length === 0;
523+
statusWatcherTimer = window.setTimeout(loadJobsStatus, allCompleted ? 0 : updateJobsInterval);
519524
} else {
520525
await reloadSelectedDataset();
521526
selectedSubmittedJob = undefined;
@@ -603,7 +608,7 @@
603608
* @return {Promise<import('fractal-components/types/api').ApplyWorkflowV2|undefined>}
604609
*/
605610
async function getSelectedJob(datasetId) {
606-
const submitted = Object.values(statuses).filter((s) => s.num_submitted_images > 0);
611+
const submitted = Object.values(statuses).filter((s) => s.status === 'submitted');
607612
if (
608613
submitted.length > 0 &&
609614
selectedSubmittedJob &&

0 commit comments

Comments
 (0)