forked from hms-dbmi-cellenics/api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request hms-dbmi-cellenics#514 from biomage-org/caching-hooks
Caching hooks
- Loading branch information
Showing
12 changed files
with
141 additions
and
140 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
20 changes: 20 additions & 0 deletions
20
src/api.v2/helpers/worker/workSubmit/getCellSetsAffectingDownsampling.js
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,20 @@ | ||
const getCellSetsAffectingDownsampling = async (_experimentId, body, cellSets) => { | ||
// If not downsampling, then there's no dependency set by this getter | ||
if (!body.downsampleSettings) return ''; | ||
|
||
const { selectedCellSet, groupedTracks } = body.downsampleSettings; | ||
|
||
const selectedCellSetKeys = cellSets | ||
.find(({ key }) => key === selectedCellSet) | ||
.children.map(({ key }) => key); | ||
|
||
const groupedCellSetKeys = cellSets | ||
.filter(({ key }) => groupedTracks.includes(key)) | ||
.flatMap(({ children }) => children) | ||
.map(({ key }) => key); | ||
|
||
// Keep them in separate lists, they each represent different changes in the settings | ||
return [selectedCellSetKeys, groupedCellSetKeys]; | ||
}; | ||
|
||
module.exports = getCellSetsAffectingDownsampling; |
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
17 changes: 9 additions & 8 deletions
17
src/api.v2/helpers/worker/workSubmit/submitEmbeddingWork.js
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 was deleted.
Oops, something went wrong.
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,30 @@ | ||
const validateAndSubmitWork = require('../../../events/validateAndSubmitWork'); | ||
const generateETag = require('../generateEtag'); | ||
|
||
|
||
const submitWorkForHook = async (experimentId, authJWT, body) => { | ||
const data = { | ||
experimentId, | ||
body, | ||
}; | ||
|
||
const ETag = await generateETag(data); | ||
const now = new Date(); | ||
const timeout = 15 * 60 * 1000; // 15min in ms | ||
const timeoutDate = new Date(now.getTime() + timeout); | ||
const request = { | ||
ETag, | ||
socketId: 'randomID', | ||
experimentId, | ||
authJWT, | ||
timeout: timeoutDate.toISOString(), | ||
body, | ||
}; | ||
|
||
await validateAndSubmitWork(request); | ||
|
||
// explicitly return ETag to make it stand out more in tests and so harder to break | ||
return ETag; | ||
}; | ||
|
||
module.exports = submitWorkForHook; |
26 changes: 2 additions & 24 deletions
26
tests/api.v2/helpers/worker/__snapshots__/submitEmbeddingWork.test.js.snap
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 |
---|---|---|
@@ -1,27 +1,5 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`submitWorkEmbedding submits the work and the ETag / params are correct 1`] = ` | ||
Array [ | ||
Array [ | ||
Object { | ||
"body": Object { | ||
"config": Object { | ||
"distanceMetric": "cosine", | ||
"minimumDistance": 0.3, | ||
}, | ||
"name": "GetEmbedding", | ||
"type": "umap", | ||
"useSaved": undefined, | ||
}, | ||
"cacheUniquenessKey": null, | ||
"experimentId": "6463cb35-3e08-4e94-a181-6d155a5ca570", | ||
"extraDependencies": Array [], | ||
"extras": undefined, | ||
"qcPipelineStartDate": "2016-03-22T04:00:00.000Z", | ||
"workerVersion": 4, | ||
}, | ||
], | ||
] | ||
`; | ||
exports[`submitWorkEmbedding submits the work and the ETag / params are correct 1`] = `Array []`; | ||
|
||
exports[`submitWorkEmbedding submits the work and the ETag / params are correct 2`] = `"5c144d6e44aa4e09497a4bc5b12a285c"`; | ||
exports[`submitWorkEmbedding submits the work and the ETag / params are correct 2`] = `"163301323ab0ee82902d1574a5dcd061"`; |
30 changes: 2 additions & 28 deletions
30
tests/api.v2/helpers/worker/__snapshots__/submitMarkerHeatmapWork.test.js.snap
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 |
---|---|---|
@@ -1,31 +1,5 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`submitWorkEmbedding submits the work and the ETag / params are correct 1`] = ` | ||
Array [ | ||
Array [ | ||
Object { | ||
"body": Object { | ||
"downsampleSettings": Object { | ||
"groupedTracks": Array [ | ||
"louvain", | ||
"sample", | ||
], | ||
"hiddenCellSets": Array [], | ||
"selectedCellSet": "louvain", | ||
"selectedPoints": "All", | ||
}, | ||
"nGenes": 5, | ||
"name": "MarkerHeatmap", | ||
}, | ||
"cacheUniquenessKey": null, | ||
"experimentId": "6463cb35-3e08-4e94-a181-6d155a5ca570", | ||
"extraDependencies": undefined, | ||
"extras": undefined, | ||
"qcPipelineStartDate": "2016-03-22T04:00:00.000Z", | ||
"workerVersion": 4, | ||
}, | ||
], | ||
] | ||
`; | ||
exports[`submitWorkEmbedding submits the work and the ETag / params are correct 1`] = `Array []`; | ||
|
||
exports[`submitWorkEmbedding submits the work and the ETag / params are correct 2`] = `"31a417d5acf6614a1c041bbfefab49cb"`; | ||
exports[`submitWorkEmbedding submits the work and the ETag / params are correct 2`] = `"b37d4df92a6f1d2a3dbb6ec29960d612"`; |
Oops, something went wrong.