From a9c3b1ae8c9da452105bb8eb025cd47f35e09025 Mon Sep 17 00:00:00 2001 From: Bryan Chu Date: Mon, 23 Sep 2024 14:11:08 -0700 Subject: [PATCH 1/8] no typename --- .../packages/data-portal/app/apollo.server.ts | 2 +- .../app/graphql/getRunByIdV2.server.ts | 22 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/frontend/packages/data-portal/app/apollo.server.ts b/frontend/packages/data-portal/app/apollo.server.ts index efa0e9ead..cb4c1b3b0 100644 --- a/frontend/packages/data-portal/app/apollo.server.ts +++ b/frontend/packages/data-portal/app/apollo.server.ts @@ -22,7 +22,7 @@ export const apolloClientV2 = new ApolloClient({ fetchPolicy: 'no-cache', }, }, - cache: new InMemoryCache(), + cache: new InMemoryCache({ addTypename: false }), link: createHttpLink({ uri: process.env.API_URL_V2 ?? ENVIRONMENT_CONTEXT_DEFAULT_VALUE.API_URL_V2, }), diff --git a/frontend/packages/data-portal/app/graphql/getRunByIdV2.server.ts b/frontend/packages/data-portal/app/graphql/getRunByIdV2.server.ts index 453cc0672..161fe455c 100644 --- a/frontend/packages/data-portal/app/graphql/getRunByIdV2.server.ts +++ b/frontend/packages/data-portal/app/graphql/getRunByIdV2.server.ts @@ -151,17 +151,17 @@ const GET_RUN_BY_ID_QUERY_V2 = gql(` } # Header - # tiltseriesAggregate { # TODO(bchu): Uncomment when __typename bug is fixed. - # aggregate { - # count - # avg { - # tiltSeriesQuality - # } - # # sum { - # # tiltseriesFramesCount # TODO(bchu): Uncomment when populated. - # # } - # } - # } + tiltseriesAggregate { # TODO(bchu): Uncomment when __typename bug is fixed. + aggregate { + count + avg { + tiltSeriesQuality + } + # sum { + # tiltseriesFramesCount # TODO(bchu): Uncomment when populated. + # } + } + } } # Annotations table From 3dc4be251037b1259e82c685db7ae3cdb3cff19f Mon Sep 17 00:00:00 2001 From: Bryan Chu Date: Wed, 25 Sep 2024 12:25:35 -0700 Subject: [PATCH 2/8] add typename --- frontend/packages/data-portal/app/apollo.server.ts | 2 +- frontend/packages/data-portal/e2e/apollo.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/packages/data-portal/app/apollo.server.ts b/frontend/packages/data-portal/app/apollo.server.ts index cb4c1b3b0..84ace687c 100644 --- a/frontend/packages/data-portal/app/apollo.server.ts +++ b/frontend/packages/data-portal/app/apollo.server.ts @@ -22,7 +22,7 @@ export const apolloClientV2 = new ApolloClient({ fetchPolicy: 'no-cache', }, }, - cache: new InMemoryCache({ addTypename: false }), + cache: new InMemoryCache({ addTypename: false }), // TODO(bchu): Re-enable __typename when fixed in BE. link: createHttpLink({ uri: process.env.API_URL_V2 ?? ENVIRONMENT_CONTEXT_DEFAULT_VALUE.API_URL_V2, }), diff --git a/frontend/packages/data-portal/e2e/apollo.ts b/frontend/packages/data-portal/e2e/apollo.ts index 348608711..efd1c562f 100644 --- a/frontend/packages/data-portal/e2e/apollo.ts +++ b/frontend/packages/data-portal/e2e/apollo.ts @@ -17,9 +17,10 @@ export function getApolloClient() { } export function getApolloClientV2() { + console.log(process.env.API_URL_V2) return new apollo.ApolloClient({ ssrMode: true, - cache: new apollo.InMemoryCache(), + cache: new apollo.InMemoryCache({ addTypename: false }), // TODO(bchu): Re-enable __typename when fixed in BE. link: apollo.createHttpLink({ uri: process.env.API_URL_V2 ?? ENVIRONMENT_CONTEXT_DEFAULT_VALUE.API_URL_V2, From e6fe1d06abc1905ac79b4ddb4283d8270d886a9a Mon Sep 17 00:00:00 2001 From: Bryan Chu Date: Wed, 25 Sep 2024 12:27:11 -0700 Subject: [PATCH 3/8] remove comment --- .../packages/data-portal/app/graphql/getRunByIdV2.server.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/packages/data-portal/app/graphql/getRunByIdV2.server.ts b/frontend/packages/data-portal/app/graphql/getRunByIdV2.server.ts index 161fe455c..4da97bc3a 100644 --- a/frontend/packages/data-portal/app/graphql/getRunByIdV2.server.ts +++ b/frontend/packages/data-portal/app/graphql/getRunByIdV2.server.ts @@ -151,7 +151,7 @@ const GET_RUN_BY_ID_QUERY_V2 = gql(` } # Header - tiltseriesAggregate { # TODO(bchu): Uncomment when __typename bug is fixed. + tiltseriesAggregate { aggregate { count avg { From 70c5a00af4af582ac78df6da7ef169fcd29b068f Mon Sep 17 00:00:00 2001 From: Bryan Chu Date: Wed, 25 Sep 2024 12:40:18 -0700 Subject: [PATCH 4/8] remove typename --- .../app/graphql/getRunByIdDiffer.ts | 34 ++++++------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/frontend/packages/data-portal/app/graphql/getRunByIdDiffer.ts b/frontend/packages/data-portal/app/graphql/getRunByIdDiffer.ts index 2aedf920e..30951c3a2 100644 --- a/frontend/packages/data-portal/app/graphql/getRunByIdDiffer.ts +++ b/frontend/packages/data-portal/app/graphql/getRunByIdDiffer.ts @@ -27,15 +27,11 @@ export function logIfHasDiff( const v1Transformed: GetRunByIdV2Query = { runs: v1.runs.map((run) => ({ - __typename: 'Run', id: run.id, name: run.name, tiltseries: { - __typename: 'TiltseriesConnection', edges: run.tiltseries.map((runTiltseries) => ({ - __typename: 'TiltseriesEdge', node: { - __typename: 'Tiltseries', accelerationVoltage: runTiltseries.acceleration_voltage, alignedTiltseriesBinning: runTiltseries.aligned_tiltseries_binning, binningFromFrames: runTiltseries.binning_from_frames, @@ -67,7 +63,6 @@ export function logIfHasDiff( })), }, dataset: { - __typename: 'Dataset', cellComponentName: run.dataset.cell_component_name, cellComponentId: run.dataset.cell_component_id, cellName: run.dataset.cell_name, @@ -95,22 +90,16 @@ export function logIfHasDiff( tissueId: run.dataset.tissue_id, title: run.dataset.title, fundingSources: { - __typename: 'DatasetFundingConnection', edges: run.dataset.funding_sources.map((source) => ({ - __typename: 'DatasetFundingEdge', node: { - __typename: 'DatasetFunding', fundingAgencyName: source.funding_agency_name, grantId: source.grant_id, }, })), }, authors: { - __typename: 'DatasetAuthorConnection', edges: run.dataset.authors.map((author) => ({ - __typename: 'DatasetAuthorEdge', node: { - __typename: 'DatasetAuthor', correspondingAuthorStatus: author.corresponding_author_status, email: author.email, name: author.name, @@ -121,19 +110,13 @@ export function logIfHasDiff( }, }, tomogramVoxelSpacings: { - __typename: 'TomogramVoxelSpacingConnection', edges: run.tomogram_voxel_spacings.map((tomogramVoxelSpacing) => ({ - __typename: 'TomogramVoxelSpacingEdge', node: { - __typename: 'TomogramVoxelSpacing', id: tomogramVoxelSpacing.id, s3Prefix: tomogramVoxelSpacing.s3_prefix!, tomograms: { - __typename: 'TomogramConnection', edges: tomogramVoxelSpacing.tomograms.map((tomogram) => ({ - __typename: 'TomogramEdge', node: { - __typename: 'Tomogram', ctfCorrected: tomogram.ctf_corrected, fiducialAlignmentStatus: tomogram.fiducial_alignment_status as Fiducial_Alignment_Status_Enum, @@ -153,7 +136,6 @@ export function logIfHasDiff( sizeZ: tomogram.size_z, voxelSpacing: tomogram.voxel_spacing, alignment: { - __typename: 'Alignment', affineTransformationMatrix: JSON.stringify( tomogram.affine_transformation_matrix, ).replaceAll(',', ', '), @@ -164,9 +146,19 @@ export function logIfHasDiff( }, })), }, + tiltseriesAggregate: { + aggregate: [ + { + count: run.tiltseries_aggregate.aggregate?.count, + avg: { + tiltSeriesQuality: + run.tiltseries_aggregate.aggregate?.avg?.tilt_series_quality, + }, + }, + ], + }, })), tomograms: v1.tomograms.map((tomogram) => ({ - __typename: 'Tomogram', ctfCorrected: tomogram.ctf_corrected, fiducialAlignmentStatus: tomogram.fiducial_alignment_status as Fiducial_Alignment_Status_Enum, @@ -193,17 +185,13 @@ export function logIfHasDiff( tomogramVoxelSpacing: tomogram.tomogram_voxel_spacing != null ? { - __typename: 'TomogramVoxelSpacing', id: tomogram.tomogram_voxel_spacing.id, s3Prefix: tomogram.tomogram_voxel_spacing.s3_prefix!, } : undefined, authors: { - __typename: 'TomogramAuthorConnection', edges: tomogram.authors.map((author) => ({ - __typename: 'TomogramAuthorEdge', node: { - __typename: 'TomogramAuthor', primaryAuthorStatus: author.primary_author_status, correspondingAuthorStatus: author.corresponding_author_status, name: author.name, From 0608158db0c9234bf3bf2fb4ad44d5b40c5127be Mon Sep 17 00:00:00 2001 From: Bryan Chu Date: Wed, 25 Sep 2024 12:40:58 -0700 Subject: [PATCH 5/8] remove onsole log --- frontend/packages/data-portal/e2e/apollo.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/packages/data-portal/e2e/apollo.ts b/frontend/packages/data-portal/e2e/apollo.ts index efd1c562f..e9b9bcc1f 100644 --- a/frontend/packages/data-portal/e2e/apollo.ts +++ b/frontend/packages/data-portal/e2e/apollo.ts @@ -17,7 +17,6 @@ export function getApolloClient() { } export function getApolloClientV2() { - console.log(process.env.API_URL_V2) return new apollo.ApolloClient({ ssrMode: true, cache: new apollo.InMemoryCache({ addTypename: false }), // TODO(bchu): Re-enable __typename when fixed in BE. From e25dfda1cecbe61bbd1b7bbd967d68fd81a80af6 Mon Sep 17 00:00:00 2001 From: Bryan Chu Date: Wed, 25 Sep 2024 13:35:28 -0700 Subject: [PATCH 6/8] add back frames --- .../packages/data-portal/app/graphql/getRunByIdDiffer.ts | 4 ++++ .../data-portal/app/graphql/getRunByIdV2.server.ts | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/frontend/packages/data-portal/app/graphql/getRunByIdDiffer.ts b/frontend/packages/data-portal/app/graphql/getRunByIdDiffer.ts index 30951c3a2..a5900d871 100644 --- a/frontend/packages/data-portal/app/graphql/getRunByIdDiffer.ts +++ b/frontend/packages/data-portal/app/graphql/getRunByIdDiffer.ts @@ -24,6 +24,10 @@ export function logIfHasDiff( for (const tomogram of v2.tomograms) { delete tomogram.deposition } + // Frames are not populated in V2 yet. + for (const run of v2.runs) { + delete run.framesAggregate + } const v1Transformed: GetRunByIdV2Query = { runs: v1.runs.map((run) => ({ diff --git a/frontend/packages/data-portal/app/graphql/getRunByIdV2.server.ts b/frontend/packages/data-portal/app/graphql/getRunByIdV2.server.ts index 4da97bc3a..2ee889da6 100644 --- a/frontend/packages/data-portal/app/graphql/getRunByIdV2.server.ts +++ b/frontend/packages/data-portal/app/graphql/getRunByIdV2.server.ts @@ -151,15 +151,17 @@ const GET_RUN_BY_ID_QUERY_V2 = gql(` } # Header + framesAggregate { + aggregate { + count + } + } tiltseriesAggregate { aggregate { count avg { tiltSeriesQuality } - # sum { - # tiltseriesFramesCount # TODO(bchu): Uncomment when populated. - # } } } } From c64042bc456fe5bfe39a084b232f56154d05b5eb Mon Sep 17 00:00:00 2001 From: Bryan Chu Date: Wed, 25 Sep 2024 13:44:09 -0700 Subject: [PATCH 7/8] add alignments --- .../packages/data-portal/app/components/Run/RunHeader.tsx | 4 +++- .../packages/data-portal/app/graphql/getRunByIdDiffer.ts | 6 ++++-- .../data-portal/app/graphql/getRunByIdV2.server.ts | 7 +++++++ frontend/packages/data-portal/app/hooks/useRunById.ts | 3 +++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/frontend/packages/data-portal/app/components/Run/RunHeader.tsx b/frontend/packages/data-portal/app/components/Run/RunHeader.tsx index a5d1c8ce9..5bd0ca30d 100644 --- a/frontend/packages/data-portal/app/components/Run/RunHeader.tsx +++ b/frontend/packages/data-portal/app/components/Run/RunHeader.tsx @@ -50,6 +50,7 @@ export function RunHeader() { resolutions, annotationFilesAggregates, tomogramsCount, + alignmentsCount, } = useRunById() const { toggleDrawer } = useMetadataDrawer() const { t } = useI18n() @@ -143,7 +144,8 @@ export function RunHeader() { }, { key: t('alignmentFile'), - value: '', // TODO(bchu): Confirm how this should be counted. + value: + alignmentsCount > 0 ? t('available') : t('notSubmitted'), }, { key: t('tomograms'), diff --git a/frontend/packages/data-portal/app/graphql/getRunByIdDiffer.ts b/frontend/packages/data-portal/app/graphql/getRunByIdDiffer.ts index a5900d871..3370602a1 100644 --- a/frontend/packages/data-portal/app/graphql/getRunByIdDiffer.ts +++ b/frontend/packages/data-portal/app/graphql/getRunByIdDiffer.ts @@ -10,7 +10,7 @@ import { Tomogram_Reconstruction_Method_Enum, } from 'app/__generated_v2__/graphql' -/* eslint-disable no-console */ +/* eslint-disable no-console, no-param-reassign */ export function logIfHasDiff( url: string, v1: GetRunByIdQuery, @@ -18,8 +18,9 @@ export function logIfHasDiff( ): void { console.log('Checking for run query diffs') - // eslint-disable-next-line no-param-reassign v2 = structuredClone(v2) + // There are no alignments in V1. + delete v2.alignmentsAggregate.aggregate // Tomogram deposition relations in V1 are incomplete. for (const tomogram of v2.tomograms) { delete tomogram.deposition @@ -162,6 +163,7 @@ export function logIfHasDiff( ], }, })), + alignmentsAggregate: {}, tomograms: v1.tomograms.map((tomogram) => ({ ctfCorrected: tomogram.ctf_corrected, fiducialAlignmentStatus: diff --git a/frontend/packages/data-portal/app/graphql/getRunByIdV2.server.ts b/frontend/packages/data-portal/app/graphql/getRunByIdV2.server.ts index 2ee889da6..69fe04c91 100644 --- a/frontend/packages/data-portal/app/graphql/getRunByIdV2.server.ts +++ b/frontend/packages/data-portal/app/graphql/getRunByIdV2.server.ts @@ -166,6 +166,13 @@ const GET_RUN_BY_ID_QUERY_V2 = gql(` } } + # Header + alignmentsAggregate(where: {run: {id: {_eq: $id}}}) { + aggregate { + count + } + } + # Annotations table # TODO(bchu) diff --git a/frontend/packages/data-portal/app/hooks/useRunById.ts b/frontend/packages/data-portal/app/hooks/useRunById.ts index 6483a1f1c..7299e11e2 100644 --- a/frontend/packages/data-portal/app/hooks/useRunById.ts +++ b/frontend/packages/data-portal/app/hooks/useRunById.ts @@ -47,6 +47,8 @@ export function useRunById() { const tomogramsCount = v1.tomograms_aggregate.aggregate?.count ?? 0 + const alignmentsCount = v2.alignmentsAggregate.aggregate?.[0]?.count ?? 0 + const { deposition } = v1 return { @@ -60,6 +62,7 @@ export function useRunById() { resolutions, annotationFilesAggregates, tomogramsCount, + alignmentsCount, deposition, } } From 6f1d4116bc4a98e5628276992c463055c017a517 Mon Sep 17 00:00:00 2001 From: Bryan Chu Date: Wed, 25 Sep 2024 14:24:38 -0700 Subject: [PATCH 8/8] update text --- frontend/packages/data-portal/app/components/Run/RunHeader.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/packages/data-portal/app/components/Run/RunHeader.tsx b/frontend/packages/data-portal/app/components/Run/RunHeader.tsx index 5bd0ca30d..63ab5e655 100644 --- a/frontend/packages/data-portal/app/components/Run/RunHeader.tsx +++ b/frontend/packages/data-portal/app/components/Run/RunHeader.tsx @@ -143,7 +143,7 @@ export function RunHeader() { : 'text-sds-color-primitive-gray-500', }, { - key: t('alignmentFile'), + key: t('alignment'), value: alignmentsCount > 0 ? t('available') : t('notSubmitted'), },