Skip to content

Commit

Permalink
Save gem2s pipeline handle (#120)
Browse files Browse the repository at this point in the history
* created gem2s endpoint

* added skeleton parameter to state-machine-definition tests

* passing all required params

* fixed qc-pipeline skeleton

* fixed gem2s pipeline skeleton name

* renamed ARN to avoid clashes

* converted gem2s pipeline steps into normal ones instead of maps

* added last steps for gem2s

* removed testing clutter

* fixed some tests

* Save gem2s pipeline handle

Co-authored-by: Pol Alvarez <[email protected]>
Co-authored-by: Martin Fosco <[email protected]>
  • Loading branch information
3 people authored May 25, 2021
1 parent ba97ffc commit b6804f0
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 6 deletions.
12 changes: 10 additions & 2 deletions src/api/route-services/experiment.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class ExperimentService {
return prettyData;
}

async savePipelineHandle(experimentId, handle) {
async saveHandle(experimentId, handle, service) {
const dynamodb = createDynamoDbInstance();
let key = { experimentId };

Expand All @@ -257,7 +257,7 @@ class ExperimentService {
const params = {
TableName: this.experimentsTableName,
Key: key,
UpdateExpression: 'set meta.pipeline = :x',
UpdateExpression: `set meta.${service} = :x`,
ExpressionAttributeValues: data,
};

Expand All @@ -266,6 +266,14 @@ class ExperimentService {
const prettyData = convertToJsObject(result.Attributes);
return prettyData;
}

async saveQCHandle(experimentId, handle) {
return this.saveHandle(experimentId, handle, 'pipeline');
}

async saveGem2sHandle(experimentId, handle) {
return this.saveHandle(experimentId, handle, 'gem2s');
}
}

module.exports = ExperimentService;
3 changes: 2 additions & 1 deletion src/api/routes/gem2s.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const getBackendStatus = require('../general-services/backend-status');
const pipelineResponse = require('../route-services/pipeline-response');
const parseSNSMessage = require('../../utils/parse-sns-message');
const logger = require('../../utils/logging');

const { expressAuthorizationMiddleware } = require('../../utils/authMiddlewares');

module.exports = {
Expand All @@ -23,7 +24,7 @@ module.exports = {
createGem2SPipeline(req.params.experimentId)
.then((data) => {
const experimentService = new ExperimentService();
experimentService.savePipelineHandle(req.params.experimentId, data)
experimentService.saveGem2sHandle(req.params.experimentId, data)
.then(() => res.json(data));
})
.catch(next);
Expand Down
3 changes: 1 addition & 2 deletions src/api/routes/pipelines.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ module.exports = {
},
],
'pipelines#create': [
expressAuthorizationMiddleware,
(req, res, next) => {
const { processingConfig } = req.body;

createQCPipeline(req.params.experimentId, processingConfig || [])
.then((data) => {
const experimentService = new ExperimentService();
experimentService.savePipelineHandle(req.params.experimentId, data)
experimentService.saveQCHandle(req.params.experimentId, data)
.then(() => res.json(data));
})
.catch(next);
Expand Down
25 changes: 24 additions & 1 deletion tests/api/route-services/experiment.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ describe('tests for the experiment service', () => {
const updateItemSpy = mockDynamoUpdateItem();
const dynamoTestData = AWS.DynamoDB.Converter.marshall({ ':x': jsTestData });

(new ExperimentService()).savePipelineHandle('12345', jsTestData)
(new ExperimentService()).saveQCHandle('12345', jsTestData)
.then(() => {
expect(updateItemSpy).toHaveBeenCalledWith(
{
Expand All @@ -249,4 +249,27 @@ describe('tests for the experiment service', () => {
})
.then(() => done());
});

it('Set gem2s Handle works', async (done) => {
const jsTestData = {
stateMachineArn: 'STATE-MACHINE-ID',
executionArn: 'EXECUTION-ID',
};

const updateItemSpy = mockDynamoUpdateItem();
const dynamoTestData = AWS.DynamoDB.Converter.marshall({ ':x': jsTestData });

(new ExperimentService()).saveGem2sHandle('12345', jsTestData)
.then(() => {
expect(updateItemSpy).toHaveBeenCalledWith(
{
TableName: 'experiments-test',
Key: { experimentId: { S: '12345' } },
UpdateExpression: 'set meta.gem2s = :x',
ExpressionAttributeValues: dynamoTestData,
},
);
})
.then(() => done());
});
});

0 comments on commit b6804f0

Please sign in to comment.