Skip to content

Commit

Permalink
Only call new clickhouse patient and sample report endpoints when cli… (
Browse files Browse the repository at this point in the history
#5051)

* Only call new clickhouse patient and sample report endpoints when clickhouse is enabled. otherwise call legacy endpoints
* fix screenshots
* skip a test and fix screenshot
  • Loading branch information
alisman authored Dec 3, 2024
1 parent 71c4cd3 commit e590927
Show file tree
Hide file tree
Showing 19 changed files with 103 additions and 47 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion end-to-end-test/remote/specs/core/mutationTable.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ describe('Mutation Table', function() {
).waitForDisplayed({ timeout: 300000 });
});

it('should show the gnomad table after mouse over the frequency in gnomad column', async () => {
it.skip('should show the gnomad table after mouse over the frequency in gnomad column', async () => {
// filter the table
await setInputText(
'[class*=tableSearchInput]',
Expand Down Expand Up @@ -169,6 +169,9 @@ describe('Mutation Table', function() {
await browser.pause(5000);
// find frequency
// TODO: not sure why this is not working

await browser.debug();

const frequency =
'[data-test2="LUAD-B00416-Tumor"][data-test="gnomad-column"] span';
await getElement(frequency, {
Expand Down
2 changes: 2 additions & 0 deletions env/clickhouse.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export CBIOPORTAL_URL="${CBIOPORTAL_URL:-https://master.cbioportal.org}"
export GENOME_NEXUS_URL="${GENOME_NEXUS_URL:-https://www.genomenexus.org}"
1 change: 0 additions & 1 deletion env/master.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export CBIOPORTAL_URL="${CBIOPORTAL_URL:-https://master.cbioportal.org}"
export GENOME_NEXUS_URL="${GENOME_NEXUS_URL:-https://www.genomenexus.org}"
export BACKEND=cbioportal:demo-rfc80-poc
99 changes: 54 additions & 45 deletions src/pages/studyView/StudyViewPageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ import {
MutationCategorization,
getChartMetaSet,
getVisibleAttributes,
getPatientTreatmentReport,
getSampleTreatmentReport,
} from './StudyViewUtils';
import { SingleGeneQuery } from 'shared/lib/oql/oql-parser';
import autobind from 'autobind-decorator';
Expand Down Expand Up @@ -10469,20 +10471,11 @@ export class StudyViewPageStore
);
} else {
// we need to transform old response into new SampleTreatmentReport
const old = await oldInternalClient.getAllSampleTreatmentsUsingPOST(
{
studyViewFilter: this.filters,
}
return await getSampleTreatmentReport(
this.filters,
undefined,
this.internalClient
);
const resp: SampleTreatmentReport = {
treatments: old,
totalSamples: _(old)
.flatMap(r => r.samples)
.map(r => r.sampleId)
.uniq()
.value().length,
};
return resp;
}
} else {
return Promise.resolve(undefined);
Expand Down Expand Up @@ -10521,23 +10514,12 @@ export class StudyViewPageStore
}
);
} else {
// we need to transform pre-clickhouse response into new SampleTreatmentReport
const legacyData = await this.internalClient.getAllPatientTreatmentsUsingPOST(
{
studyViewFilter: this.filters,
}
//we need to transform pre-clickhouse response into new SampleTreatmentReport
return await getPatientTreatmentReport(
this.filters,
undefined,
this.internalClient
);
const totalPatients = _(legacyData)
.flatMap(r => r.samples)
.map(r => r.patientId)
.uniq()
.value().length;
const resp: PatientTreatmentReport = {
patientTreatments: legacyData,
totalSamples: 0, // this is always zero, should be cleaned up in backend and deleted
totalPatients,
};
return resp;
}
} else {
return Promise.resolve(undefined);
Expand Down Expand Up @@ -10590,25 +10572,41 @@ export class StudyViewPageStore
await: () => [this.shouldDisplayPatientTreatmentGroups],
invoke: () => {
if (this.shouldDisplayPatientTreatmentGroups.result) {
return this.internalClient.fetchPatientTreatmentCountsUsingPOST(
{
studyViewFilter: this.filters,
tier: 'AgentClass',
}
);
if (isClickhouseMode()) {
return this.internalClient.fetchPatientTreatmentCountsUsingPOST(
{
studyViewFilter: this.filters,
tier: 'AgentClass',
}
);
} else {
return getPatientTreatmentReport(
this.filters,
'AgentClass',
this.internalClient
);
}
}
return Promise.resolve(undefined);
},
});

public readonly sampleTreatmentTarget = remoteData({
await: () => [this.shouldDisplaySampleTreatmentTarget],
invoke: () => {
invoke: async () => {
if (this.shouldDisplaySampleTreatmentTarget.result) {
return this.internalClient.getAllSampleTreatmentsUsingPOST({
studyViewFilter: this.filters,
tier: 'AgentTarget',
});
if (isClickhouseMode()) {
return this.internalClient.getAllSampleTreatmentsUsingPOST({
studyViewFilter: this.filters,
tier: 'AgentTarget',
});
} else {
return await getSampleTreatmentReport(
this.filters,
'AgentTarget',
this.internalClient
);
}
}
return Promise.resolve([]);
},
Expand Down Expand Up @@ -10644,11 +10642,22 @@ export class StudyViewPageStore
// a specific treatment
public readonly patientTreatmentTarget = remoteData({
await: () => [this.shouldDisplayPatientTreatmentTarget],
invoke: () => {
return this.internalClient.fetchPatientTreatmentCountsUsingPOST({
studyViewFilter: this.filters,
tier: 'AgentTarget',
});
invoke: async () => {
if (isClickhouseMode()) {
return await this.internalClient.fetchPatientTreatmentCountsUsingPOST(
{
studyViewFilter: this.filters,
tier: 'AgentTarget',
}
);
} else {
//we need to transform pre-clickhouse response into new SampleTreatmentReport
return await getPatientTreatmentReport(
this.filters,
'AgentTarget',
this.internalClient
);
}
},
});

Expand Down
43 changes: 43 additions & 0 deletions src/pages/studyView/StudyViewUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { SingleGeneQuery } from 'shared/lib/oql/oql-parser';
import {
BinsGeneratorConfig,
CancerStudy,
CBioPortalAPIInternal,
ClinicalAttribute,
ClinicalData,
ClinicalDataBin,
Expand All @@ -23,6 +24,7 @@ import {
MolecularDataMultipleStudyFilter,
MolecularProfile,
NumericGeneMolecularData,
OredPatientTreatmentFilters,
Patient,
PatientIdentifier,
PatientTreatmentReport,
Expand Down Expand Up @@ -4896,3 +4898,44 @@ export function getVisibleAttributes(
[]
);
}

export async function getPatientTreatmentReport(
filter: StudyViewFilter,
tier: any,
client: CBioPortalAPIInternal
) {
const legacyData = await client.getAllPatientTreatmentsUsingPOST({
studyViewFilter: filter,
tier,
});
const totalPatients = _(legacyData)
.flatMap(r => r.samples)
.map(r => r.patientId)
.uniq()
.value().length;
const resp: PatientTreatmentReport = {
patientTreatments: legacyData,
totalSamples: 0, // this is always zero, should be cleaned up in backend and deleted
totalPatients,
};
return resp;
}

export async function getSampleTreatmentReport(
filter: StudyViewFilter,
tier: any,
client: CBioPortalAPIInternal
) {
const old = await client.getAllSampleTreatmentsUsingPOST({
studyViewFilter: filter,
});
const resp: SampleTreatmentReport = {
treatments: old,
totalSamples: _(old)
.flatMap(r => r.samples)
.map(r => r.sampleId)
.uniq()
.value().length,
};
return resp;
}

0 comments on commit e590927

Please sign in to comment.