Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rerendering cluster names #769

Merged
merged 11 commits into from
Jul 14, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Array [
"name": "GetExpressionCellSets",
},
180,
"bff42d1a0fd631bdb2a72de335468764",
"59933d6066e7194a95003acb680a2c9b",
Object {
"PipelineRunETag": "2021-10-20T12:51:44.755Z",
"broadcast": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Array [
],
},
60,
"97ad02a589a9066c83a355836f1c667e",
"9f493b777975162a6fa0a8d480cb0c09",
Object {
"PipelineRunETag": "2021-01-01T01:01:01.000Z",
"broadcast": false,
Expand Down
2 changes: 1 addition & 1 deletion src/__test__/utils/work/fetchWork.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jest.mock('utils/cache', () => require('__test__/utils/work/fetchWork.mock').moc
jest.mock('utils/work/seekWorkResponse', () => require('__test__/utils/work/fetchWork.mock').mockSeekWorkResponseModule);

const experimentId = '1234';
const NON_GENE_EXPRESSION_ETAG = '013c3026bb7156d222ccd18919745195'; // pragma: allowlist secret
const NON_GENE_EXPRESSION_ETAG = '3ebcb92e53c10a67614c6dcc12f8c8d4'; // pragma: allowlist secret
const GENE_EXPRESSION_ETAG = '34c05c9d07fd24ce0c22d2bec7fd7437'; // pragma: allowlist secret
const timeout = 10;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,19 @@ const DotPlotPage = (props) => {
} = useSelector((state) => state.genes.properties.views[plotUuid] || {});

const cellSets = useSelector(getCellSets());



const {
loading: cellSetsLoading,
error: cellSetsError,
hierarchy: cellSetHierarcy,
properties: cellSetProperties,
} = cellSets;


const clusterNames = Object.values(cellSetProperties).map((el) => el.name);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you should get the values here clusterNames here. Implementing it here would add another parameter to be passed to fetchPlotDataWork. I think it would be better to attach clusterNames inside the body request body that's generated for this plot.


const [moreThanTwoGroups, setMoreThanTwoGroups] = useState(false);
const experimentName = useSelector((state) => state.experimentSettings.info.experimentName);
const csvFileName = fileNames(experimentName, 'DOT_PLOT', [config?.selectedCellSet, config?.selectedPoints]);
Expand Down Expand Up @@ -183,7 +189,7 @@ const DotPlotPage = (props) => {
const currentComparedConfig = getComparedConfig(config);
if (config && !_.isEqual(previousComparedConfig.current, currentComparedConfig)) {
previousComparedConfig.current = currentComparedConfig;
dispatch(fetchPlotDataWork(experimentId, plotUuid, plotType));
dispatch(fetchPlotDataWork(experimentId, plotUuid, plotType, clusterNames));
}
}, [config, cellSetProperties]);

Expand Down Expand Up @@ -292,7 +298,7 @@ const DotPlotPage = (props) => {
<PlatformError
description='Error loading plot data.'
reason='Check the options that you have selected and try again.'
onClick={() => dispatch(fetchPlotDataWork(experimentId, plotUuid, plotType))}
onClick={() => dispatch(fetchPlotDataWork(experimentId, plotUuid, plotType, clusterNames))}
/>
</center>
);
Expand Down
9 changes: 7 additions & 2 deletions src/redux/actions/componentConfig/fetchPlotDataWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ import endUserMessages from 'utils/endUserMessages';
import generatePlotWorkBody from 'utils/work/generatePlotWorkBody';
import { fetchWork } from 'utils/work/fetchWork';

const fetchPlotDataWork = (experimentId, plotUuid, plotType) => async (dispatch, getState) => {
const fetchPlotDataWork = (
experimentId,
plotUuid,
plotType,
clusterNames,
) => async (dispatch, getState) => {
const config = getState().componentConfig[plotUuid]?.config ?? initialPlotConfigStates[plotType];
const timeout = getTimeoutForWorkerTask(getState(), 'PlotData');

Expand All @@ -20,7 +25,7 @@ const fetchPlotDataWork = (experimentId, plotUuid, plotType) => async (dispatch,
});

const data = await fetchWork(
experimentId, body, getState, { timeout },
experimentId, body, getState, { timeout, clusterNames },
);

dispatch({
Expand Down
15 changes: 13 additions & 2 deletions src/utils/work/fetchWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,13 @@ const fetchWork = async (
getState,
optionals = {},
) => {
const { extras = undefined, timeout = 180, broadcast = false } = optionals;
const {
extras = undefined,
timeout = 180,
broadcast = false,
clusterNames = undefined,
Copy link
Member

@ivababukova ivababukova Jul 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not using these optionals and extras and adding the cluster names in them?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FetchWork function is used for fetching every work, clusterNames are something specific to just some of the fetchWork calls, then why would we want to introduce a new parameter for fetchWork that is relevant only to some work types?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is exactly Agi's point which I agree with. I put the cluster names in the dot plot's work body where they are relevant. I also didn't like how I did it initially but was not sure how to pass them otherwise. I think now it should be good

} = optionals;

const backendStatus = getBackendStatus(experimentId)(getState()).status;

const { environment } = getState().networkResources;
Expand Down Expand Up @@ -135,7 +141,12 @@ const fetchWork = async (
}

const ETag = createObjectHash({
experimentId, body, qcPipelineStartDate, extras, cacheUniquenessKey,
experimentId,
body,
qcPipelineStartDate,
extras,
cacheUniquenessKey,
clusterNames,
});

// First, let's try to fetch this information from the local cache.
Expand Down