-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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 * Save response to dynamodb * Add gem2s handle and status report to status * Fix dynamodb updates to experiments and other minor things * Fix tests and minor bugs * Minor fixes Co-authored-by: Pol Alvarez <[email protected]> Co-authored-by: Martin Fosco <[email protected]>
- Loading branch information
1 parent
c50f429
commit bf1d71b
Showing
15 changed files
with
249 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
const AWSXRay = require('aws-xray-sdk'); | ||
|
||
const constants = require('../general-services/pipeline-manage/constants'); | ||
const validateRequest = require('../../utils/schema-validator'); | ||
const logger = require('../../utils/logging'); | ||
|
||
const ExperimentService = require('./experiment'); | ||
const SamplesService = require('./samples'); | ||
|
||
const experimentService = new ExperimentService(); | ||
const samplesService = new SamplesService(); | ||
const getPipelineStatus = require('../general-services/pipeline-status'); | ||
|
||
const sendUpdateToSubscribed = async (experimentId, message, io) => { | ||
const statusRes = await getPipelineStatus(experimentId, constants.GEM2S_PROCESS_NAME); | ||
|
||
// How do we handle errors? TODO This needs to be handled | ||
// if (statusRes.gem2s) { | ||
// AWSXRay.getSegment().addError(error); | ||
// io.sockets.emit(`ExperimentUpdates-${experimentId}`, message); | ||
// return; | ||
// } | ||
|
||
// Concatenate into a proper response. | ||
const response = { | ||
...message, | ||
status: statusRes, | ||
type: 'gem2s', | ||
}; | ||
|
||
logger.log('Sending to all clients subscribed to experiment', experimentId); | ||
io.sockets.emit(`ExperimentUpdates-${experimentId}`, response); | ||
}; | ||
|
||
const gem2sResponse = async (io, message) => { | ||
AWSXRay.getSegment().addMetadata('message', message); | ||
|
||
// Fail hard if there was an error. | ||
await validateRequest(message, 'GEM2SResponse.v1.yaml'); | ||
|
||
const { experimentId } = message; | ||
|
||
if (!message.table) { | ||
await sendUpdateToSubscribed(experimentId, message, io); | ||
return; | ||
} | ||
|
||
const { item, table: tableName } = message; | ||
|
||
if (tableName.includes('experiments')) { | ||
await experimentService.updateExperiment(experimentId, item); | ||
} else if (tableName.includes('samples')) { | ||
const { projectUuid } = item; | ||
await samplesService.updateSamples(projectUuid, item); | ||
} | ||
|
||
await sendUpdateToSubscribed(experimentId, message, io); | ||
}; | ||
|
||
module.exports = gem2sResponse; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.