Skip to content

Commit

Permalink
Merge branch 'master' of github.com:biomage-org/ui into refactor-etag
Browse files Browse the repository at this point in the history
Signed-off-by: Pol Alvarez <[email protected]>
  • Loading branch information
kafkasl committed Oct 25, 2023
2 parents 0cc687f + 3a97656 commit a313509
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe('Normalized matrix index page', () => {

await waitFor(() => {
expect(writeToFileURL).toHaveBeenCalledWith(result);
expect(downloadFromUrl).toHaveBeenCalledWith(writeToFileURLResult, 'NormalizedExpression.csv');
expect(downloadFromUrl).toHaveBeenCalledWith(writeToFileURLResult, 'NormalizedExpression.csv.gz');
});
});

Expand Down Expand Up @@ -159,7 +159,7 @@ describe('Normalized matrix index page', () => {

await waitFor(() => {
expect(writeToFileURL).toHaveBeenCalledWith(result);
expect(downloadFromUrl).toHaveBeenCalledWith(writeToFileURLResult, 'NormalizedExpression.csv');
expect(downloadFromUrl).toHaveBeenCalledWith(writeToFileURLResult, 'NormalizedExpression.csv.gz');
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const downloadNormalizedMatrix = (
dispatch,
);

downloadFromUrl(writeToFileURL(data), 'NormalizedExpression.csv');
downloadFromUrl(writeToFileURL(data), 'NormalizedExpression.csv.gz');

dispatch({
type: PLOT_DATA_LOADED,
Expand Down
4 changes: 2 additions & 2 deletions src/utils/getTimeoutForWorkerTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const getTimeoutForWorkerTask = (state, taskName) => {
switch (taskName) {
case 'GetEmbedding':
case 'ListGenes':
case 'MarkerHeatmap': {
case 'MarkerHeatmap':
case 'GetNormalizedExpression': {
// all of this calls can happen at the same time and each of them can potentially have to
// wait for the others to finish before it starts processing (due to the SQS) so the timeout
// needs to be large enough for the slowest task to finish
Expand All @@ -36,7 +37,6 @@ const getTimeoutForWorkerTask = (state, taskName) => {
case 'GeneExpression':
case 'GetMitochondrialContent':
case 'GetDoubletScore':
case 'GetNormalizedExpression':
case 'DownloadAnnotSeuratObject':
case 'DifferentialExpression':
case 'GetNUmis':
Expand Down
4 changes: 1 addition & 3 deletions src/utils/work/dispatchWorkRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const dispatchWorkRequest = async (

console.log('dispatching work request', request);
// TODO test what happens when api throws an error here
const response = await fetchAPI(
const { data: { ETag, signedUrl } } = await fetchAPI(
`/v2/workRequest/${experimentId}`,
{
method: 'POST',
Expand All @@ -58,8 +58,6 @@ const dispatchWorkRequest = async (
},
);

console.log('work request response', response);
const { data: { ETag, signedUrl } } = response;
return { ETag, signedUrl, request };
};

Expand Down
38 changes: 0 additions & 38 deletions src/utils/work/fetchWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,6 @@ import dispatchWorkRequest from 'utils/work/dispatchWorkRequest';
import downloadFromS3 from 'utils/work/downloadFromS3';
import waitForWorkRequest from './waitForWorkRequest';

// Temporarily using gene expression without local cache
// const fetchGeneExpressionWorkWithoutLocalCache = async (
// experimentId,
// timeout,
// body,
// backendStatus,
// environment,
// broadcast,
// extras,
// dispatch,
// ) => {
// // If new genes are needed, construct payload, try S3 for results,
// // and send out to worker if there's a miss.
// const { pipeline: { startDate: qcPipelineStartDate } } = backendStatus;

// // const ETag = await generateETag(
// // experimentId,
// // body,
// // extras,
// // qcPipelineStartDate,
// // environment,
// // dispatch,
// // getState,
// // );

// const { ETag, signedUrl, data } = await sendWorkRequest(
// experimentId,
// body,
// timeout,
// {
// broadcast,
// ...extras,
// },
// dispatch,
// );

// return data ?? await downloadFromS3(body.name, signedUrl);
// };
// retrieveData will try to get the data for the given experimentId and ETag from
// the fastest source possible. It will try to get the data in order from:
// 1. Browser cache
Expand Down
2 changes: 1 addition & 1 deletion src/utils/work/unpackResult.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { decompress } from 'fflate';

const unpackResult = async (storageResp, taskName = null) => {
// SeuratObject can fail to download when loaded into memory
if (taskName === 'DownloadAnnotSeuratObject') {
if (taskName === 'DownloadAnnotSeuratObject' || taskName === 'GetNormalizedExpression') {
const blob = await storageResp.blob();
return (blob);
}
Expand Down
3 changes: 2 additions & 1 deletion src/utils/work/waitForWorkRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ const getWorkerTimeout = (taskName, defaultTimeout) => {
switch (taskName) {
case 'GetEmbedding':
case 'ListGenes':
case 'MarkerHeatmap': {
case 'MarkerHeatmap':
case 'GetNormalizedExpression': {
return dayjs().add(1800, 's').toISOString();
}

Expand Down

0 comments on commit a313509

Please sign in to comment.