From bd86fd9234430a00550917de9d762ba87b380bc4 Mon Sep 17 00:00:00 2001 From: Martin Fosco Date: Fri, 12 Mar 2021 12:37:19 -0300 Subject: [PATCH 1/4] Add pipeline status to pipeline updates to avoid having to call GET pipeline on the ui every time we need to know its status --- src/api/route-services/pipeline-response.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/api/route-services/pipeline-response.js b/src/api/route-services/pipeline-response.js index 19a77f8db..dda6e0ae8 100644 --- a/src/api/route-services/pipeline-response.js +++ b/src/api/route-services/pipeline-response.js @@ -4,6 +4,7 @@ const logger = require('../../utils/logging'); const ExperimentService = require('./experiment'); const PlotsTablesService = require('./plots-tables'); +const pipelineStatus = require('../general-services/pipeline-status'); const experimentService = new ExperimentService(); const plotsTableService = new PlotsTablesService(); @@ -85,10 +86,13 @@ const pipelineResponse = async (io, message) => { experimentService.updateProcessingConfig(experimentId, [{ name: taskName, body: output.config }]); + const statusResult = await pipelineStatus(experimentId); + // Concatenate into a proper response. const response = { ...message, output, + status: statusResult, }; logger.log('Sending to all clients subscribed to experiment', experimentId); From 06dd848bda79ea26bc7ec476ed2bfe0a0a91c4e4 Mon Sep 17 00:00:00 2001 From: Martin Fosco Date: Fri, 12 Mar 2021 15:17:40 -0300 Subject: [PATCH 2/4] Fix tests --- src/api/route-services/pipeline-response.js | 4 ++-- tests/api/route-services/pipeline-response.test.js | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/api/route-services/pipeline-response.js b/src/api/route-services/pipeline-response.js index dda6e0ae8..169f4ee09 100644 --- a/src/api/route-services/pipeline-response.js +++ b/src/api/route-services/pipeline-response.js @@ -86,13 +86,13 @@ const pipelineResponse = async (io, message) => { experimentService.updateProcessingConfig(experimentId, [{ name: taskName, body: output.config }]); - const statusResult = await pipelineStatus(experimentId); + const statusRes = await pipelineStatus(experimentId); // Concatenate into a proper response. const response = { ...message, output, - status: statusResult, + status: statusRes, }; logger.log('Sending to all clients subscribed to experiment', experimentId); diff --git a/tests/api/route-services/pipeline-response.test.js b/tests/api/route-services/pipeline-response.test.js index 4a9c4657f..584c2c28f 100644 --- a/tests/api/route-services/pipeline-response.test.js +++ b/tests/api/route-services/pipeline-response.test.js @@ -6,6 +6,10 @@ const ioServer = require('socket.io')({ const AWS = require('../../../src/utils/requireAWS'); const pipelineResponse = require('../../../src/api/route-services/pipeline-response'); +jest.mock('../../../src/api/general-services/pipeline-status', () => jest.fn().mockImplementation(() => ({ + pipelineStatus: () => ({}), +}))); + describe('Test Pipeline Response Service', () => { let io; let client; From 38fe67885b41bf21eebd9dba4e5d4ec43e572015 Mon Sep 17 00:00:00 2001 From: Martin Fosco Date: Mon, 15 Mar 2021 08:47:57 -0300 Subject: [PATCH 3/4] WIP --- src/api/route-services/pipeline-response.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/api/route-services/pipeline-response.js b/src/api/route-services/pipeline-response.js index 169f4ee09..d4084a19d 100644 --- a/src/api/route-services/pipeline-response.js +++ b/src/api/route-services/pipeline-response.js @@ -42,6 +42,9 @@ const plotsInTables = { }; const pipelineResponse = async (io, message) => { + console.log('messageDebug'); + console.log(JSON.stringify(message)); + await validateRequest(message, 'PipelineResponse.v1.yaml'); // Fail hard if there was an error. From 60b2ebb287b3e4c02ab58e9ab5c1edf0b9caaee2 Mon Sep 17 00:00:00 2001 From: Martin Fosco Date: Mon, 15 Mar 2021 11:04:54 -0300 Subject: [PATCH 4/4] Remove console log --- src/api/route-services/pipeline-response.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/api/route-services/pipeline-response.js b/src/api/route-services/pipeline-response.js index d4084a19d..169f4ee09 100644 --- a/src/api/route-services/pipeline-response.js +++ b/src/api/route-services/pipeline-response.js @@ -42,9 +42,6 @@ const plotsInTables = { }; const pipelineResponse = async (io, message) => { - console.log('messageDebug'); - console.log(JSON.stringify(message)); - await validateRequest(message, 'PipelineResponse.v1.yaml'); // Fail hard if there was an error.