From 3a777ebef839f5d15833d3fd76f2eb3ce5709712 Mon Sep 17 00:00:00 2001 From: Vincent Selhorst-Jones Date: Thu, 10 Jul 2025 18:30:56 -0700 Subject: [PATCH 1/6] WIP: Datasets for deposition query --- .../getDatasetsForDepositionV2.server.ts | 123 ++++++++++++++++++ .../graphql/getVoodooExperimentV2.server.ts | 33 +++++ .../app/hooks/useDepositionById.ts | 19 ++- .../app/routes/depositions.$id.tsx | 35 +++++ 4 files changed, 209 insertions(+), 1 deletion(-) create mode 100644 frontend/packages/data-portal/app/graphql/getDatasetsForDepositionV2.server.ts create mode 100644 frontend/packages/data-portal/app/graphql/getVoodooExperimentV2.server.ts diff --git a/frontend/packages/data-portal/app/graphql/getDatasetsForDepositionV2.server.ts b/frontend/packages/data-portal/app/graphql/getDatasetsForDepositionV2.server.ts new file mode 100644 index 000000000..116871c52 --- /dev/null +++ b/frontend/packages/data-portal/app/graphql/getDatasetsForDepositionV2.server.ts @@ -0,0 +1,123 @@ +/** + * Pulls all datasets associated with a deposition. + * Three ways for a dataset to be associated: + * 1) Direct association, the dataset says it belong to deposition. + * 2) The dataset contains a tomogram that belongs to deposition. + * 3) The dataset contains an annotation that belongs to deposition. + * ^^^ Note: For #3, we actually do counts off shape so more useful elsewhere + * + * It's possible for any combo of these 3 to be true simultaneously. + * HOWEVER, for the expand depositions work, we don't actually care about #1. + * We only expose datasets through context of user viewing annotations or tomograms, + * so if a dataset only is associated because of #1, it's not used in current UX + * (although I think it would be very weird for a dataset to be owned by a deposition + * but have no tomograms or annotations in that dataset also owned). + * + * Additionally, we might care about tracking which datasets are associated due to + * #2 or #3. For instance, to show the "Group by" of datasets (and runs), you wouldn't + * want to have a line dedicated to a dataset that only has tomograms for the deposition + * if you're currently viewing the annotations tab. + * + * For the queries in this file, the use of the `count` is not immediately used for + * purposes of collecting all the datasets based on #2 or #3, it's mostly there because + * we can't run `groupBy` queries without a `count` in place. However, it does have the + * benefit of being useful for displaying count info on the "Group by" accordion rows + * (ex: Dataset ABC has ?? runs | ## annotations), we can use the results from this to + * pull the count of annotations / tomograms for a given dataset. (And can sum up against + * it for getting the count on an organism, since an organism is really just a list of datasets.) + * Note: For #3, we actually provide the counts off the # AnnotationShapes, not just + * the annotations since it's the former that is how we present # annotations in UX. + */ +import { + ApolloClient, + ApolloQueryResult, + NormalizedCacheObject, +} from '@apollo/client' + +import { gql } from 'app/__generated_v2__' +import { GetDatasetsForDepositionViaAnnotationShapesQuery, GetDatasetsForDepositionViaTomogramsQuery } from 'app/__generated_v2__/graphql' + +const GET_DATASETS_FOR_DEPOSITION_VIA_TOMOGRAMS = gql(` + query getDatasetsForDepositionViaTomograms( + $depositionId: Int! + ) { + tomogramsAggregate(where: {depositionId: {_eq: $depositionId}}) { + aggregate { + count(columns: id) + groupBy { + run { + dataset { + id + title + organismName + organismTaxid + } + } + } + } + } + } +`) + +// Strictly speaking, we can get the dataset info just as easily off annotations. +// But instead by pulling this off the AnnotationShapes, the count is accurate +// for how we display # annotations to the user (# shapes, not parent annotations) +const GET_DATASETS_FOR_DEPOSITION_VIA_ANNOTATION_SHAPES = gql(` + query getDatasetsForDepositionViaAnnotationShapes( + $depositionId: Int! + ) { + annotationShapesAggregate( + where: { + annotation: { + depositionId: {_eq: $depositionId} + } + } + ) { + aggregate { + count(columns: id) + groupBy { + annotation { + run { + dataset { + id + title + organismName + organismTaxid + } + } + } + } + } + } + } +`) + +export async function getDatasetsForDepositionViaTomograms({ + client, + depositionId, +}: { + client: ApolloClient + depositionId: number +}): Promise> { + return client.query({ + query: GET_DATASETS_FOR_DEPOSITION_VIA_TOMOGRAMS, + variables: { + depositionId, + } + }) +} + +export async function getDatasetsForDepositionViaAnnotationShapes({ + client, + depositionId, +}: { + client: ApolloClient + depositionId: number +}): Promise> { + return client.query({ + query: GET_DATASETS_FOR_DEPOSITION_VIA_ANNOTATION_SHAPES, + variables: { + depositionId, + } + }) +} diff --git a/frontend/packages/data-portal/app/graphql/getVoodooExperimentV2.server.ts b/frontend/packages/data-portal/app/graphql/getVoodooExperimentV2.server.ts new file mode 100644 index 000000000..8dc077008 --- /dev/null +++ b/frontend/packages/data-portal/app/graphql/getVoodooExperimentV2.server.ts @@ -0,0 +1,33 @@ +import type { + ApolloClient, + ApolloQueryResult, + NormalizedCacheObject, +} from '@apollo/client' + +import { gql } from 'app/__generated_v2__' +import { PerformVoodooQuery } from 'app/__generated_v2__/graphql' + +const VOODOO = gql(` + query PerformVoodoo( + $id: Int! + ) { + depositions(where: { id: { _eq: $id }}) { + depositionDate + } + } +`) + +export async function getVoodoo({ + client, + id, +}: { + client: ApolloClient + id: number +}): Promise> { + return client.query({ + query: VOODOO, + variables: { + id, + }, + }) +} diff --git a/frontend/packages/data-portal/app/hooks/useDepositionById.ts b/frontend/packages/data-portal/app/hooks/useDepositionById.ts index 6d40bcf4d..4869c4893 100644 --- a/frontend/packages/data-portal/app/hooks/useDepositionById.ts +++ b/frontend/packages/data-portal/app/hooks/useDepositionById.ts @@ -4,9 +4,12 @@ import { useTypedLoaderData } from 'remix-typedjson' import { Annotation_Method_Link_Type_Enum, Annotation_Method_Type_Enum, + GetDatasetsForDepositionViaAnnotationShapesQuery, + GetDatasetsForDepositionViaTomogramsQuery, type GetDepositionAnnotationsQuery, GetDepositionByIdV2Query, type GetDepositionTomogramsQuery, + PerformVoodooQuery, } from 'app/__generated_v2__/graphql' import { METHOD_TYPE_ORDER } from 'app/constants/methodTypes' @@ -23,12 +26,26 @@ export interface AnnotationMethodMetadata { } export function useDepositionById() { - const { v2, annotations, tomograms } = useTypedLoaderData<{ + const { + v2, + annotations, + tomograms, + voodooData, + datasetsViaTomograms, + datasetsViaAnnotationShapes, + } = useTypedLoaderData<{ v2: GetDepositionByIdV2Query annotations?: GetDepositionAnnotationsQuery tomograms?: GetDepositionTomogramsQuery + voodooData: PerformVoodooQuery + datasetsViaTomograms: GetDatasetsForDepositionViaTomogramsQuery + datasetsViaAnnotationShapes: GetDatasetsForDepositionViaAnnotationShapesQuery }>() + console.log("voodooData", voodooData); // REMOVE + console.log("datasetsViaTomograms", datasetsViaTomograms); // REMOVE + console.log("datasetsViaAnnotationShapes", datasetsViaAnnotationShapes); // REMOVE + const annotationMethods: AnnotationMethodMetadata[] = useMemo(() => { const annotationMethodToMetadata = new Map< string, diff --git a/frontend/packages/data-portal/app/routes/depositions.$id.tsx b/frontend/packages/data-portal/app/routes/depositions.$id.tsx index 03e0ca189..5c63c16e9 100644 --- a/frontend/packages/data-portal/app/routes/depositions.$id.tsx +++ b/frontend/packages/data-portal/app/routes/depositions.$id.tsx @@ -22,6 +22,11 @@ import { DEPOSITION_FILTERS } from 'app/constants/filterQueryParams' import { QueryParams } from 'app/constants/query' import { getDepositionAnnotations } from 'app/graphql/getDepositionAnnotationsV2.server' import { getDepositionByIdV2 } from 'app/graphql/getDepositionByIdV2.server' +import {getVoodoo} from 'app/graphql/getVoodooExperimentV2.server' +import { + getDatasetsForDepositionViaTomograms, + getDatasetsForDepositionViaAnnotationShapes, +} from 'app/graphql/getDatasetsForDepositionV2.server' import { getDepositionTomograms } from 'app/graphql/getDepositionTomogramsV2.server' import { useDatasetsFilterData } from 'app/hooks/useDatasetsFilterData' import { useDepositionById } from 'app/hooks/useDepositionById' @@ -35,6 +40,7 @@ import { getFeatureFlag, useFeatureFlag } from 'app/utils/featureFlags' import { shouldRevalidatePage } from 'app/utils/revalidate' export async function loader({ params, request }: LoaderFunctionArgs) { + console.log("HELLO VOODOO FROM DEPOSITION LOADER"); // REMOVE const url = new URL(request.url) const id = params.id ? +params.id : NaN @@ -65,6 +71,28 @@ export async function loader({ params, request }: LoaderFunctionArgs) { params: url.searchParams, }) + // VOODOO Begin Vincent work, giant block of example query usage, not for real use! + const voodooResponse = await getVoodoo({ + client, + id, + }) + console.log("voodooResponse", voodooResponse); // REMOVE + console.log("voodooResponse.data.depositions", voodooResponse.data.depositions); // REMOVE + const voodooData = voodooResponse.data; + + const { data: datasetsViaTomograms } = await getDatasetsForDepositionViaTomograms({ + client, + depositionId: id, + }) + + const { data: datasetsViaAnnotationShapes } = await getDatasetsForDepositionViaAnnotationShapes({ + client, + depositionId: id, + }) + + // END VOODOO End Vincent work for requests to GraphQL + // There is more Vincent stuff put in to the response and the use hook + if (responseV2.depositions.length === 0) { throw new Response(null, { status: 404, @@ -116,6 +144,10 @@ export async function loader({ params, request }: LoaderFunctionArgs) { v2: responseV2, annotations: data && 'annotationShapes' in data ? data : undefined, tomograms: data && 'tomograms' in data ? data : undefined, + // VOODOO below this line is Vincent demo stuff + voodooData: voodooData, + datasetsViaTomograms, + datasetsViaAnnotationShapes, }) } @@ -149,6 +181,9 @@ export function shouldRevalidate(args: ShouldRevalidateFunctionArgs) { export default function DepositionByIdPage() { const { deposition, annotationsCount, tomogramsCount } = useDepositionById() + console.log("deposition", deposition); // REMOVE + console.log("annotationsCount", annotationsCount); // REMOVE + console.log("tomogramsCount", tomogramsCount); // REMOVE const { filteredDatasetsCount, totalDatasetsCount } = useDatasetsFilterData() const { t } = useI18n() From ce49b5e2d7c930753f4c7f64944831711c37ad51 Mon Sep 17 00:00:00 2001 From: Vincent Selhorst-Jones Date: Fri, 11 Jul 2025 17:22:00 -0700 Subject: [PATCH 2/6] WIP: Filtering based on deposition and datasets --- .../getDatasetsForDepositionV2.server.ts | 6 + .../getDepositionAnnotationsV2.server.ts | 115 +++++++++++++++++- .../app/hooks/useDepositionById.ts | 7 ++ .../app/routes/depositions.$id.tsx | 34 +++++- 4 files changed, 157 insertions(+), 5 deletions(-) diff --git a/frontend/packages/data-portal/app/graphql/getDatasetsForDepositionV2.server.ts b/frontend/packages/data-portal/app/graphql/getDatasetsForDepositionV2.server.ts index 116871c52..a56176824 100644 --- a/frontend/packages/data-portal/app/graphql/getDatasetsForDepositionV2.server.ts +++ b/frontend/packages/data-portal/app/graphql/getDatasetsForDepositionV2.server.ts @@ -27,6 +27,12 @@ * it for getting the count on an organism, since an organism is really just a list of datasets.) * Note: For #3, we actually provide the counts off the # AnnotationShapes, not just * the annotations since it's the former that is how we present # annotations in UX. + * + * We are not trying to limit the returned results at all since we need to know _all_ the + * datasets at once to present it to the user. This should be safe because the number of datasets + * is fairly limited and the amount of data we pull per dataset is pretty small. + * If this eventually becomes an issue (say, CryoET has lots more datasets in the future and + * some wacky deposition has 1 thing in every single one of them), we'll have to rethink stuff. */ import { ApolloClient, diff --git a/frontend/packages/data-portal/app/graphql/getDepositionAnnotationsV2.server.ts b/frontend/packages/data-portal/app/graphql/getDepositionAnnotationsV2.server.ts index 96f252c9c..d1c46e9c1 100644 --- a/frontend/packages/data-portal/app/graphql/getDepositionAnnotationsV2.server.ts +++ b/frontend/packages/data-portal/app/graphql/getDepositionAnnotationsV2.server.ts @@ -1,3 +1,16 @@ +/** + * - Created new version of GET_DEPOSITION_ANNOTATIONS that handles sorting and dataset filtering + * - Note the `pageSize` arg for the function to do client query on above + * This is necessary because we serve the same kind of data whether we filter based on user + * directly filtering for a dataset or doing a "Group by" on organism, BUT the page size of + * those two cases is different (20 for the former, 5 for the latter) + * - Possible we could optimize the annotationFiles out of existence, pull the path from + * the Annotation path (either s3MetadataPath or httpsMetadataPath, same diff for the + * number we want out of the path), but I don't know if different shapes have different + * files or they all belong to the same file somehow, needs more data exploration. + * - I didn't have time to write the equivalent version of this for tomograms, but I think it will + * be extremely similar. Sorry! + */ import type { ApolloClient, ApolloQueryResult, @@ -5,7 +18,7 @@ import type { } from '@apollo/client' import { gql } from 'app/__generated_v2__' -import type { GetDepositionAnnotationsQuery } from 'app/__generated_v2__/graphql' +import type { GetDepositionAnnotationsForDatasetsQuery, GetDepositionAnnotationsQuery } from 'app/__generated_v2__/graphql' import { MAX_PER_PAGE } from 'app/constants/pagination' const GET_DEPOSITION_ANNOTATIONS = gql(` @@ -60,6 +73,82 @@ const GET_DEPOSITION_ANNOTATIONS = gql(` } `) +// I expect there's some way to pass a `null` sort of datasetIds filter that instead +// will not perform a filter on dataset ids, but I didn't have time to explore how, so +// // for now we just have two queries. +const GET_DEPOSITION_ANNOTATIONS_FOR_DATASETS = gql(` + query GetDepositionAnnotationsForDatasets( + $depositionId: Int!, + $datasetIds: [Int!]!, + $limit: Int!, + $offset: Int!, + ) { + annotationShapes( + where: { + annotation: { + depositionId: { + _eq: $depositionId + }, + run: { + datasetId:{ + _in: $datasetIds + }, + }, + }, + }, + limitOffset: { + limit: $limit, + offset: $offset, + }, + orderBy: [ + { + annotation: { + groundTruthStatus: desc + } + }, + { + annotation: { + depositionDate: desc + } + }, + { + annotation: { + id: desc + } + } + ] + ) { + id + shapeType + + annotation { + groundTruthStatus + id + methodType + objectName + + run { + id + name + + dataset { + id + title + } + } + } + + annotationFiles(first: 1) { + edges { + node { + s3Path + } + } + } + } + } +`) + export async function getDepositionAnnotations({ client, id, @@ -78,3 +167,27 @@ export async function getDepositionAnnotations({ }, }) } + +export async function getDepositionAnnotationsForDatasets({ + client, + depositionId, + datasetIds, + pageSize = MAX_PER_PAGE, + page, +}: { + client: ApolloClient + depositionId: number + datasetIds: number[] + pageSize?: number + page: number +}): Promise> { + return client.query({ + query: GET_DEPOSITION_ANNOTATIONS_FOR_DATASETS, + variables: { + depositionId, + datasetIds, + limit: pageSize, + offset: (page - 1) * pageSize, + }, + }) +} diff --git a/frontend/packages/data-portal/app/hooks/useDepositionById.ts b/frontend/packages/data-portal/app/hooks/useDepositionById.ts index 4869c4893..755c44b9b 100644 --- a/frontend/packages/data-portal/app/hooks/useDepositionById.ts +++ b/frontend/packages/data-portal/app/hooks/useDepositionById.ts @@ -7,6 +7,7 @@ import { GetDatasetsForDepositionViaAnnotationShapesQuery, GetDatasetsForDepositionViaTomogramsQuery, type GetDepositionAnnotationsQuery, + GetDepositionAnnotationsForDatasetsQuery, GetDepositionByIdV2Query, type GetDepositionTomogramsQuery, PerformVoodooQuery, @@ -33,6 +34,8 @@ export function useDepositionById() { voodooData, datasetsViaTomograms, datasetsViaAnnotationShapes, + runCountsForDepositionAnnotations, + annotationShapesForDatasets, } = useTypedLoaderData<{ v2: GetDepositionByIdV2Query annotations?: GetDepositionAnnotationsQuery @@ -40,11 +43,15 @@ export function useDepositionById() { voodooData: PerformVoodooQuery datasetsViaTomograms: GetDatasetsForDepositionViaTomogramsQuery datasetsViaAnnotationShapes: GetDatasetsForDepositionViaAnnotationShapesQuery + runCountsForDepositionAnnotations: GetDepositionAnnoRunsForDatasetsQuery + annotationShapesForDatasets: GetDepositionAnnotationsForDatasetsQuery }>() console.log("voodooData", voodooData); // REMOVE console.log("datasetsViaTomograms", datasetsViaTomograms); // REMOVE console.log("datasetsViaAnnotationShapes", datasetsViaAnnotationShapes); // REMOVE + console.log("runCountsForDepositionAnnotations", runCountsForDepositionAnnotations); // REMOVE + console.log("annotationShapesForDatasets", annotationShapesForDatasets); // REMOVE const annotationMethods: AnnotationMethodMetadata[] = useMemo(() => { const annotationMethodToMetadata = new Map< diff --git a/frontend/packages/data-portal/app/routes/depositions.$id.tsx b/frontend/packages/data-portal/app/routes/depositions.$id.tsx index 5c63c16e9..35c4c28ed 100644 --- a/frontend/packages/data-portal/app/routes/depositions.$id.tsx +++ b/frontend/packages/data-portal/app/routes/depositions.$id.tsx @@ -20,13 +20,17 @@ import { TablePageLayout } from 'app/components/TablePageLayout' import { TableCountHeader } from 'app/components/TablePageLayout/TableCountHeader' import { DEPOSITION_FILTERS } from 'app/constants/filterQueryParams' import { QueryParams } from 'app/constants/query' -import { getDepositionAnnotations } from 'app/graphql/getDepositionAnnotationsV2.server' +import { + getDepositionAnnotations, + getDepositionAnnotationsForDatasets, +} from 'app/graphql/getDepositionAnnotationsV2.server' import { getDepositionByIdV2 } from 'app/graphql/getDepositionByIdV2.server' import {getVoodoo} from 'app/graphql/getVoodooExperimentV2.server' import { getDatasetsForDepositionViaTomograms, getDatasetsForDepositionViaAnnotationShapes, } from 'app/graphql/getDatasetsForDepositionV2.server' +import { getDepositionAnnoRunsForDatasets } from 'app/graphql/getDepositionRunsV2.server' import { getDepositionTomograms } from 'app/graphql/getDepositionTomogramsV2.server' import { useDatasetsFilterData } from 'app/hooks/useDatasetsFilterData' import { useDepositionById } from 'app/hooks/useDepositionById' @@ -90,6 +94,29 @@ export async function loader({ params, request }: LoaderFunctionArgs) { depositionId: id, }) + // PROGRAMATICALLY PULL the following array based on boiling down one of the two + // `datasetsViaBlah` results into the datasets associated with either anno or tomo flavor. + // Sorry I didn't have time to write the code for extracting these dataset ids! + const EXAMPLE_ALL_DATASET_IDS = [10301, 10302] + const { data: runCountsForDepositionAnnotations} = await getDepositionAnnoRunsForDatasets({ + client, + depositionId: id, + datasetIds: EXAMPLE_ALL_DATASET_IDS, + }) + + // MANUALLY SET the following array based on deposition you are dev-ing against. + // Here as a rough example of how user interaction would go. For deposition id 10314 + // it has two datasets of id 10301 and 10302, so we choose some subset of those. + const EXAMPLE_FILTERED_DATASET_IDS = [10301] + const { data: annotationShapesForDatasets } = await getDepositionAnnotationsForDatasets({ + client, + depositionId: id, + datasetIds: EXAMPLE_FILTERED_DATASET_IDS, + page: 1, + }) + + + // END VOODOO End Vincent work for requests to GraphQL // There is more Vincent stuff put in to the response and the use hook @@ -148,6 +175,8 @@ export async function loader({ params, request }: LoaderFunctionArgs) { voodooData: voodooData, datasetsViaTomograms, datasetsViaAnnotationShapes, + runCountsForDepositionAnnotations, + annotationShapesForDatasets, }) } @@ -181,9 +210,6 @@ export function shouldRevalidate(args: ShouldRevalidateFunctionArgs) { export default function DepositionByIdPage() { const { deposition, annotationsCount, tomogramsCount } = useDepositionById() - console.log("deposition", deposition); // REMOVE - console.log("annotationsCount", annotationsCount); // REMOVE - console.log("tomogramsCount", tomogramsCount); // REMOVE const { filteredDatasetsCount, totalDatasetsCount } = useDatasetsFilterData() const { t } = useI18n() From 35f7eca8dc972c1b569a97c6cb5afea87466df20 Mon Sep 17 00:00:00 2001 From: Vincent Selhorst-Jones Date: Fri, 11 Jul 2025 17:22:29 -0700 Subject: [PATCH 3/6] WIP: Pull run count info for deposition --- .../app/graphql/getDepositionRunsV2.server.ts | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 frontend/packages/data-portal/app/graphql/getDepositionRunsV2.server.ts diff --git a/frontend/packages/data-portal/app/graphql/getDepositionRunsV2.server.ts b/frontend/packages/data-portal/app/graphql/getDepositionRunsV2.server.ts new file mode 100644 index 000000000..9862c685d --- /dev/null +++ b/frontend/packages/data-portal/app/graphql/getDepositionRunsV2.server.ts @@ -0,0 +1,64 @@ +/** + * Pull run info pertaining to a specific deposition, either in annotation or tomogram flavor. + * + * Getting the count of runs for a deposition is a two-step process. + * 1. Pull the ids for all datasets associated with the deposition (for either anno or tomo flavor). + * 2. Get the count of runs where they belong to one of above datasets and the deposition + * I believe this is necessary due to how the GraphQL resolves, we can't just do it in a single + * query. But because we already have to get all the dataset info to be able to populate the + * dataset filter, we have #1 on hand, and we only need the info from #2 if the user clicks into + * the "Group By" for Deposited Location (to show the # Runs in an unexpanded dataset accordion). + * + * There is no pagination on counting, because we have a core assumption of the number of datasets + * never being so big it forces paging of top-level dataset info. + */ +import type { + ApolloClient, + ApolloQueryResult, + NormalizedCacheObject, +} from '@apollo/client' + +import { gql } from 'app/__generated_v2__' +import { GetDepositionAnnoRunsForDatasetsQuery } from 'app/__generated_v2__/graphql' + + +const GET_DEPOSITION_ANNO_RUNS_FOR_DATASETS = gql(` + query GetDepositionAnnoRunsForDatasets( + $depositionId: Int!, + $datasetIds: [Int!]!, + ) { + runsAggregate( + where: { + annotations: {depositionId: {_eq: $depositionId}} + datasetId: {_in: $datasetIds}, + } + ) { + aggregate { + count(columns: id) + groupBy { + dataset { + id + } + } + } + } + } +`) + +export async function getDepositionAnnoRunsForDatasets({ + client, + depositionId, + datasetIds, +}: { + client: ApolloClient + depositionId: number + datasetIds: number[] +}): Promise> { + return client.query({ + query: GET_DEPOSITION_ANNO_RUNS_FOR_DATASETS, + variables: { + depositionId, + datasetIds, + } + }) +} \ No newline at end of file From 2ac79570e7eacdf18b56ce6f212ccb0d6b43ce38 Mon Sep 17 00:00:00 2001 From: Vincent Selhorst-Jones Date: Sat, 12 Jul 2025 03:07:29 -0700 Subject: [PATCH 4/6] WIP: Pull runs for the dataset+deposition --- .../data-portal/app/constants/pagination.ts | 8 ++ .../app/graphql/getDepositionRunsV2.server.ts | 102 ++++++++++++++++-- .../app/hooks/useDepositionById.ts | 7 +- .../app/routes/depositions.$id.tsx | 23 +++- 4 files changed, 127 insertions(+), 13 deletions(-) diff --git a/frontend/packages/data-portal/app/constants/pagination.ts b/frontend/packages/data-portal/app/constants/pagination.ts index 40bf6d3d9..f948400f4 100644 --- a/frontend/packages/data-portal/app/constants/pagination.ts +++ b/frontend/packages/data-portal/app/constants/pagination.ts @@ -1,5 +1,13 @@ export const MAX_PER_PAGE = 20 +/** + * When displaying a group of accordions, we page them out by 10s. + * Inside of the accordion, once the lowest level of an accordion is + * expanded, we page the content inside of it by 5s. + */ +export const MAX_PER_ACCORDION_GROUP = 10 +export const MAX_PER_FULLY_OPEN_ACCORDION = 5 + /** * Max number of annotated objects to show for dataset. */ diff --git a/frontend/packages/data-portal/app/graphql/getDepositionRunsV2.server.ts b/frontend/packages/data-portal/app/graphql/getDepositionRunsV2.server.ts index 9862c685d..35378ba21 100644 --- a/frontend/packages/data-portal/app/graphql/getDepositionRunsV2.server.ts +++ b/frontend/packages/data-portal/app/graphql/getDepositionRunsV2.server.ts @@ -1,6 +1,16 @@ /** * Pull run info pertaining to a specific deposition, either in annotation or tomogram flavor. * + * 3 types of pull here + * 1. Pulling counts of runs (either anno or tomo flavor) for the deposition + * 2. Paging through the deposition runs (anno or tomo) for a specific dataset + * 3. Getting all the annos/tomos of a deposition for a specific run + * + * Each of the above pull types will need a variant for each flavor, doing annotation or + * tomogram version. I'm running out of time, so I'm just going to flesh out anno flavor + * of each, but the tomo flavor should be extremely similar. + * + * --- Pull 1 --- * Getting the count of runs for a deposition is a two-step process. * 1. Pull the ids for all datasets associated with the deposition (for either anno or tomo flavor). * 2. Get the count of runs where they belong to one of above datasets and the deposition @@ -8,9 +18,18 @@ * query. But because we already have to get all the dataset info to be able to populate the * dataset filter, we have #1 on hand, and we only need the info from #2 if the user clicks into * the "Group By" for Deposited Location (to show the # Runs in an unexpanded dataset accordion). + * [In retrospect, I'm not totally sure why the `datasetIds` is necessary to use for an _in filter, + * maybe you could just groupBy from the beginning. But I recall there being some issue with trying + * to go directly to it, so I'm leaving it like that. Sorry I don't have more time to explore!] * * There is no pagination on counting, because we have a core assumption of the number of datasets * never being so big it forces paging of top-level dataset info. + * + * --- Pull 2 --- + * Pull all the runs (either anno or tomo flavor) for a specific dataset that also + * belong to the deposition of interest. We don't want _all_ the runs in the dataset, + * we just want those that belong to deposition and are inside the dataset. Provides + * pagination because we can have very large numbers of runs in some cases. */ import type { ApolloClient, @@ -19,11 +38,17 @@ import type { } from '@apollo/client' import { gql } from 'app/__generated_v2__' -import { GetDepositionAnnoRunsForDatasetsQuery } from 'app/__generated_v2__/graphql' +import { + GetDepositionAnnoRunCountsForDatasetsQuery, + GetDepositionAnnoRunsForDatasetQuery, + } from 'app/__generated_v2__/graphql' + import { MAX_PER_ACCORDION_GROUP } from 'app/constants/pagination' -const GET_DEPOSITION_ANNO_RUNS_FOR_DATASETS = gql(` - query GetDepositionAnnoRunsForDatasets( + +// Annotation flavor -- TODO create a tomogram flavor as well +const GET_DEPOSITION_ANNO_RUN_COUNTS_FOR_DATASETS = gql(` + query GetDepositionAnnoRunCountsForDatasets( $depositionId: Int!, $datasetIds: [Int!]!, ) { @@ -45,7 +70,48 @@ const GET_DEPOSITION_ANNO_RUNS_FOR_DATASETS = gql(` } `) -export async function getDepositionAnnoRunsForDatasets({ +// Annotation flavor -- TODO create a tomogram flavor as well +const GET_DEPOSiTION_ANNO_RUNS_FOR_DATASET = gql(` + query GetDepositionAnnoRunsForDataset( + $depositionId: Int!, + $datasetId: Int!, + $limit: Int!, + $offset: Int! + ) { + runs( + where: { + datasetId: {_eq: $datasetId}, + annotations: {depositionId: {_eq: $depositionId}} + }, + orderBy: [{name: asc}], + limitOffset: {limit: $limit, offset: $offset} + ) { + id + name + + # Get annotation count for each run + annotationsAggregate(where: {depositionId: {_eq: $depositionId}}) { + aggregate { + count + } + } + } + + # Count of ALL matching runs (not just this page) to show "1-10 of 78 Runs", etc + runsAggregate( + where: { + datasetId: {_eq: $datasetId}, + annotations: {depositionId: {_eq: $depositionId}} + } + ) { + aggregate { + count + } + } + } +`) + +export async function getDepositionAnnoRunCountsForDatasets({ client, depositionId, datasetIds, @@ -53,12 +119,34 @@ export async function getDepositionAnnoRunsForDatasets({ client: ApolloClient depositionId: number datasetIds: number[] -}): Promise> { +}): Promise> { return client.query({ - query: GET_DEPOSITION_ANNO_RUNS_FOR_DATASETS, + query: GET_DEPOSITION_ANNO_RUN_COUNTS_FOR_DATASETS, variables: { depositionId, datasetIds, } }) -} \ No newline at end of file +} + +export async function getDepositionAnnoRunsForDataset({ + client, + depositionId, + datasetId, + page, +}: { + client: ApolloClient + depositionId: number + datasetId: number + page: number +}): Promise> { + return client.query({ + query: GET_DEPOSiTION_ANNO_RUNS_FOR_DATASET, + variables: { + depositionId, + datasetId, + limit: MAX_PER_ACCORDION_GROUP, + offset: (page - 1) * MAX_PER_ACCORDION_GROUP, + } + }) +} diff --git a/frontend/packages/data-portal/app/hooks/useDepositionById.ts b/frontend/packages/data-portal/app/hooks/useDepositionById.ts index 755c44b9b..55191398f 100644 --- a/frontend/packages/data-portal/app/hooks/useDepositionById.ts +++ b/frontend/packages/data-portal/app/hooks/useDepositionById.ts @@ -7,6 +7,8 @@ import { GetDatasetsForDepositionViaAnnotationShapesQuery, GetDatasetsForDepositionViaTomogramsQuery, type GetDepositionAnnotationsQuery, + GetDepositionAnnoRunCountsForDatasetsQuery, + GetDepositionAnnoRunsForDatasetQuery, GetDepositionAnnotationsForDatasetsQuery, GetDepositionByIdV2Query, type GetDepositionTomogramsQuery, @@ -35,6 +37,7 @@ export function useDepositionById() { datasetsViaTomograms, datasetsViaAnnotationShapes, runCountsForDepositionAnnotations, + runsAnnoForDepositionInDataset, annotationShapesForDatasets, } = useTypedLoaderData<{ v2: GetDepositionByIdV2Query @@ -43,7 +46,8 @@ export function useDepositionById() { voodooData: PerformVoodooQuery datasetsViaTomograms: GetDatasetsForDepositionViaTomogramsQuery datasetsViaAnnotationShapes: GetDatasetsForDepositionViaAnnotationShapesQuery - runCountsForDepositionAnnotations: GetDepositionAnnoRunsForDatasetsQuery + runCountsForDepositionAnnotations: GetDepositionAnnoRunCountsForDatasetsQuery + runsAnnoForDepositionInDataset: GetDepositionAnnoRunsForDatasetQuery annotationShapesForDatasets: GetDepositionAnnotationsForDatasetsQuery }>() @@ -51,6 +55,7 @@ export function useDepositionById() { console.log("datasetsViaTomograms", datasetsViaTomograms); // REMOVE console.log("datasetsViaAnnotationShapes", datasetsViaAnnotationShapes); // REMOVE console.log("runCountsForDepositionAnnotations", runCountsForDepositionAnnotations); // REMOVE + console.log("runsAnnoForDepositionInDataset", runsAnnoForDepositionInDataset); // REMOVE console.log("annotationShapesForDatasets", annotationShapesForDatasets); // REMOVE const annotationMethods: AnnotationMethodMetadata[] = useMemo(() => { diff --git a/frontend/packages/data-portal/app/routes/depositions.$id.tsx b/frontend/packages/data-portal/app/routes/depositions.$id.tsx index 35c4c28ed..51f0fcf2b 100644 --- a/frontend/packages/data-portal/app/routes/depositions.$id.tsx +++ b/frontend/packages/data-portal/app/routes/depositions.$id.tsx @@ -30,7 +30,10 @@ import { getDatasetsForDepositionViaTomograms, getDatasetsForDepositionViaAnnotationShapes, } from 'app/graphql/getDatasetsForDepositionV2.server' -import { getDepositionAnnoRunsForDatasets } from 'app/graphql/getDepositionRunsV2.server' +import { + getDepositionAnnoRunCountsForDatasets, + getDepositionAnnoRunsForDataset, +} from 'app/graphql/getDepositionRunsV2.server' import { getDepositionTomograms } from 'app/graphql/getDepositionTomogramsV2.server' import { useDatasetsFilterData } from 'app/hooks/useDatasetsFilterData' import { useDepositionById } from 'app/hooks/useDepositionById' @@ -98,12 +101,24 @@ export async function loader({ params, request }: LoaderFunctionArgs) { // `datasetsViaBlah` results into the datasets associated with either anno or tomo flavor. // Sorry I didn't have time to write the code for extracting these dataset ids! const EXAMPLE_ALL_DATASET_IDS = [10301, 10302] - const { data: runCountsForDepositionAnnotations} = await getDepositionAnnoRunsForDatasets({ + const { data: runCountsForDepositionAnnotations} = await getDepositionAnnoRunCountsForDatasets({ client, depositionId: id, datasetIds: EXAMPLE_ALL_DATASET_IDS, }) + // MANUALLY SET the following dataset id based on deposition you are dev-ing against. + // This is a rough example of how user interaction would go. For deposition id 10314, + // the user has chosen to expand the accordion of dataset id 10301, so now showing + // the run info for that dataset. + const EXAMPLE_DATASET_ID = 10301 + const { data: runsAnnoForDepositionInDataset } = await getDepositionAnnoRunsForDataset({ + client, + depositionId: id, + datasetId: EXAMPLE_DATASET_ID, + page: 1, + }) + // MANUALLY SET the following array based on deposition you are dev-ing against. // Here as a rough example of how user interaction would go. For deposition id 10314 // it has two datasets of id 10301 and 10302, so we choose some subset of those. @@ -114,9 +129,6 @@ export async function loader({ params, request }: LoaderFunctionArgs) { datasetIds: EXAMPLE_FILTERED_DATASET_IDS, page: 1, }) - - - // END VOODOO End Vincent work for requests to GraphQL // There is more Vincent stuff put in to the response and the use hook @@ -176,6 +188,7 @@ export async function loader({ params, request }: LoaderFunctionArgs) { datasetsViaTomograms, datasetsViaAnnotationShapes, runCountsForDepositionAnnotations, + runsAnnoForDepositionInDataset, annotationShapesForDatasets, }) } From 5ea08edae20d716f505ad4a249ec53905fbc4dc8 Mon Sep 17 00:00:00 2001 From: Vincent Selhorst-Jones Date: Sun, 13 Jul 2025 11:05:18 -0700 Subject: [PATCH 5/6] WIP: Query to pull paginated annos for dep+run --- .../getDepositionAnnotationsV2.server.ts | 6 + .../app/graphql/getDepositionRunsV2.server.ts | 142 +++++++++++++++++- .../app/hooks/useDepositionById.ts | 4 + .../app/routes/depositions.$id.tsx | 15 ++ 4 files changed, 164 insertions(+), 3 deletions(-) diff --git a/frontend/packages/data-portal/app/graphql/getDepositionAnnotationsV2.server.ts b/frontend/packages/data-portal/app/graphql/getDepositionAnnotationsV2.server.ts index d1c46e9c1..c78c1473e 100644 --- a/frontend/packages/data-portal/app/graphql/getDepositionAnnotationsV2.server.ts +++ b/frontend/packages/data-portal/app/graphql/getDepositionAnnotationsV2.server.ts @@ -1,5 +1,11 @@ /** * - Created new version of GET_DEPOSITION_ANNOTATIONS that handles sorting and dataset filtering + * I believe the original GET_DEPOSITION_ANNOTATIONS query will probably still be necessary + * since having two queries is still the easiest way to handle a version without and a version + * with dataset filtering. However, the original version very likely needs to bring in the + * `orderBy` clause of the newer version so it sorts the same way as the existing annotation + * tables and matches the design. (I just pulled the sorting logic from GET_RUN_BY_ID_QUERY_V2) + * since that's the approach we're trying to match, pretty sure it works here! * - Note the `pageSize` arg for the function to do client query on above * This is necessary because we serve the same kind of data whether we filter based on user * directly filtering for a dataset or doing a "Group by" on organism, BUT the page size of diff --git a/frontend/packages/data-portal/app/graphql/getDepositionRunsV2.server.ts b/frontend/packages/data-portal/app/graphql/getDepositionRunsV2.server.ts index 35378ba21..b437d0b17 100644 --- a/frontend/packages/data-portal/app/graphql/getDepositionRunsV2.server.ts +++ b/frontend/packages/data-portal/app/graphql/getDepositionRunsV2.server.ts @@ -30,6 +30,27 @@ * belong to the deposition of interest. We don't want _all_ the runs in the dataset, * we just want those that belong to deposition and are inside the dataset. Provides * pagination because we can have very large numbers of runs in some cases. + * + * --- Pull 3 --- + * Get all the annos or tomos (dependent on which flavor query you are using) for a specific + * run in the context of a single deposition. We don't want _all_ the annos/tomos in the run, + * we just want those that belong to the deposition and are inside the run. For annos specifically, + * we have to pull shapes, since that's how we actually show Annotations to the user. We provide + * pagination with this query, but strictly speaking, we don't have to: the number of annos/tomos + * that belong to a single run are usually not that many, and I'd be quite surprised if it ever + * went over 1k, so we could probably get away with grabbing all of them at once and handling + * pagination purely in the FE. Still, it's easier to just offload it to the BE and it means + * we can keep the same dev pattern as we have for Pull 2 and most of the other paginated + * stuff in the app. + * + * I'm currently providing the total count of annos/tomos available for showing pagination + * (the "1-5 of 52 Annotations" page count part), but on second thought, that's not strictly + * necessary: we already have that info from Pull 2 above. Since Pull 2 gets the count of + * annos/tomos belonging to each run in the current page of runs, this query doesn't have to + * return it as well, it's duplicate info. But maybe it makes for an easier dev experience to + * have it available? If you wind up using the count info from Pull 2 instead of Pull 3 to + * provide the pagination count stuff, probably best to cut that part here just to avoid + * future confusion since it would be dead wood. */ import type { ApolloClient, @@ -41,9 +62,13 @@ import { gql } from 'app/__generated_v2__' import { GetDepositionAnnoRunCountsForDatasetsQuery, GetDepositionAnnoRunsForDatasetQuery, + GetAnnotationsForRunAndDepositionQuery, } from 'app/__generated_v2__/graphql' - import { MAX_PER_ACCORDION_GROUP } from 'app/constants/pagination' + import { + MAX_PER_ACCORDION_GROUP, + MAX_PER_FULLY_OPEN_ACCORDION, +} from 'app/constants/pagination' // Annotation flavor -- TODO create a tomogram flavor as well @@ -71,7 +96,7 @@ const GET_DEPOSITION_ANNO_RUN_COUNTS_FOR_DATASETS = gql(` `) // Annotation flavor -- TODO create a tomogram flavor as well -const GET_DEPOSiTION_ANNO_RUNS_FOR_DATASET = gql(` +const GET_DEPOSITION_ANNO_RUNS_FOR_DATASET = gql(` query GetDepositionAnnoRunsForDataset( $depositionId: Int!, $datasetId: Int!, @@ -111,6 +136,94 @@ const GET_DEPOSiTION_ANNO_RUNS_FOR_DATASET = gql(` } `) +// Annotation flavor -- TODO create a tomogram flavor as well +// This query is very similar to GET_DEPOSITION_ANNOTATIONS_FOR_DATASETS elsewhere, +// it's just that we filter based on deposition+run rather than deposition+datasets. +const GET_ANNOTATIONS_FOR_RUN_AND_DEPOSITION = gql(` + query GetAnnotationsForRunAndDeposition( + $depositionId: Int!, + $runId: Int!, + $limit: Int!, + $offset: Int!, + ) { + annotationShapes( + where: { + annotation: { + depositionId: { + _eq: $depositionId + }, + runId: { + _eq: $runId + }, + }, + }, + limitOffset: { + limit: $limit, + offset: $offset, + }, + orderBy: [ + { + annotation: { + groundTruthStatus: desc + } + }, + { + annotation: { + depositionDate: desc + } + }, + { + annotation: { + id: desc + } + } + ] + ) { + id + shapeType + + annotation { + groundTruthStatus + id + methodType + objectName + + run { + id + name + + dataset { + id + title + } + } + } + + annotationFiles(first: 1) { + edges { + node { + s3Path + } + } + } + } + + # Count of ALL matching annos (not just this page) to show "1-5 of 52 Annotations", etc + annotationShapesAggregate( + where: { + annotation: { + depositionId: {_eq: $depositionId} + runId: {_eq: $runId}, + } + } + ) { + aggregate { + count + } + } + } +`) + export async function getDepositionAnnoRunCountsForDatasets({ client, depositionId, @@ -141,7 +254,7 @@ export async function getDepositionAnnoRunsForDataset({ page: number }): Promise> { return client.query({ - query: GET_DEPOSiTION_ANNO_RUNS_FOR_DATASET, + query: GET_DEPOSITION_ANNO_RUNS_FOR_DATASET, variables: { depositionId, datasetId, @@ -150,3 +263,26 @@ export async function getDepositionAnnoRunsForDataset({ } }) } + +export async function getAnnotationsForRunAndDeposition({ + client, + depositionId, + runId, + page, +}: { + client: ApolloClient + depositionId: number + runId: number + page: number +}): Promise> { + console.log("getAnnotationsForRunAndDeposition received page#", page); // REMOVE + return client.query({ + query: GET_ANNOTATIONS_FOR_RUN_AND_DEPOSITION, + variables: { + depositionId, + runId, + limit: MAX_PER_FULLY_OPEN_ACCORDION, + offset: (page - 1) * MAX_PER_FULLY_OPEN_ACCORDION, + } + }) +} diff --git a/frontend/packages/data-portal/app/hooks/useDepositionById.ts b/frontend/packages/data-portal/app/hooks/useDepositionById.ts index 55191398f..d65d57e56 100644 --- a/frontend/packages/data-portal/app/hooks/useDepositionById.ts +++ b/frontend/packages/data-portal/app/hooks/useDepositionById.ts @@ -13,6 +13,7 @@ import { GetDepositionByIdV2Query, type GetDepositionTomogramsQuery, PerformVoodooQuery, + GetAnnotationsForRunAndDepositionQuery, } from 'app/__generated_v2__/graphql' import { METHOD_TYPE_ORDER } from 'app/constants/methodTypes' @@ -38,6 +39,7 @@ export function useDepositionById() { datasetsViaAnnotationShapes, runCountsForDepositionAnnotations, runsAnnoForDepositionInDataset, + annotationsForRunInDeposition, annotationShapesForDatasets, } = useTypedLoaderData<{ v2: GetDepositionByIdV2Query @@ -47,6 +49,7 @@ export function useDepositionById() { datasetsViaTomograms: GetDatasetsForDepositionViaTomogramsQuery datasetsViaAnnotationShapes: GetDatasetsForDepositionViaAnnotationShapesQuery runCountsForDepositionAnnotations: GetDepositionAnnoRunCountsForDatasetsQuery + annotationsForRunInDeposition: GetAnnotationsForRunAndDepositionQuery runsAnnoForDepositionInDataset: GetDepositionAnnoRunsForDatasetQuery annotationShapesForDatasets: GetDepositionAnnotationsForDatasetsQuery }>() @@ -56,6 +59,7 @@ export function useDepositionById() { console.log("datasetsViaAnnotationShapes", datasetsViaAnnotationShapes); // REMOVE console.log("runCountsForDepositionAnnotations", runCountsForDepositionAnnotations); // REMOVE console.log("runsAnnoForDepositionInDataset", runsAnnoForDepositionInDataset); // REMOVE + console.log("annotationsForRunInDeposition", annotationsForRunInDeposition); // REMOVE console.log("annotationShapesForDatasets", annotationShapesForDatasets); // REMOVE const annotationMethods: AnnotationMethodMetadata[] = useMemo(() => { diff --git a/frontend/packages/data-portal/app/routes/depositions.$id.tsx b/frontend/packages/data-portal/app/routes/depositions.$id.tsx index 51f0fcf2b..1ca1653e4 100644 --- a/frontend/packages/data-portal/app/routes/depositions.$id.tsx +++ b/frontend/packages/data-portal/app/routes/depositions.$id.tsx @@ -33,6 +33,7 @@ import { import { getDepositionAnnoRunCountsForDatasets, getDepositionAnnoRunsForDataset, + getAnnotationsForRunAndDeposition, } from 'app/graphql/getDepositionRunsV2.server' import { getDepositionTomograms } from 'app/graphql/getDepositionTomogramsV2.server' import { useDatasetsFilterData } from 'app/hooks/useDatasetsFilterData' @@ -119,6 +120,19 @@ export async function loader({ params, request }: LoaderFunctionArgs) { page: 1, }) + // MANUALLY SET the following run id based on depostion+dataset you are dev-ing against. + // This is a rough example of how user interaction would go. For deposition id 10314, + // the user has chosen to expand the accordion of dataset id 10301, and within that, + // has selected run id 14070, so now showing annotations for that run in the deposition. + const EXAMPLE_RUN_ID = 14070 + const { data: annotationsForRunInDeposition } = await getAnnotationsForRunAndDeposition({ + client, + depositionId: id, + runId: EXAMPLE_RUN_ID, + page: 1, // VOODOO go back to 1! + }) + + // MANUALLY SET the following array based on deposition you are dev-ing against. // Here as a rough example of how user interaction would go. For deposition id 10314 // it has two datasets of id 10301 and 10302, so we choose some subset of those. @@ -189,6 +203,7 @@ export async function loader({ params, request }: LoaderFunctionArgs) { datasetsViaAnnotationShapes, runCountsForDepositionAnnotations, runsAnnoForDepositionInDataset, + annotationsForRunInDeposition, annotationShapesForDatasets, }) } From ceee9288a26a57ec83f77ae077acbcf11c211230 Mon Sep 17 00:00:00 2001 From: Vincent Selhorst-Jones Date: Sun, 13 Jul 2025 11:10:05 -0700 Subject: [PATCH 6/6] WIP: Clean up original exploration code --- .../graphql/getVoodooExperimentV2.server.ts | 33 ------------------- .../app/hooks/useDepositionById.ts | 6 ++-- .../app/routes/depositions.$id.tsx | 19 ++--------- 3 files changed, 5 insertions(+), 53 deletions(-) delete mode 100644 frontend/packages/data-portal/app/graphql/getVoodooExperimentV2.server.ts diff --git a/frontend/packages/data-portal/app/graphql/getVoodooExperimentV2.server.ts b/frontend/packages/data-portal/app/graphql/getVoodooExperimentV2.server.ts deleted file mode 100644 index 8dc077008..000000000 --- a/frontend/packages/data-portal/app/graphql/getVoodooExperimentV2.server.ts +++ /dev/null @@ -1,33 +0,0 @@ -import type { - ApolloClient, - ApolloQueryResult, - NormalizedCacheObject, -} from '@apollo/client' - -import { gql } from 'app/__generated_v2__' -import { PerformVoodooQuery } from 'app/__generated_v2__/graphql' - -const VOODOO = gql(` - query PerformVoodoo( - $id: Int! - ) { - depositions(where: { id: { _eq: $id }}) { - depositionDate - } - } -`) - -export async function getVoodoo({ - client, - id, -}: { - client: ApolloClient - id: number -}): Promise> { - return client.query({ - query: VOODOO, - variables: { - id, - }, - }) -} diff --git a/frontend/packages/data-portal/app/hooks/useDepositionById.ts b/frontend/packages/data-portal/app/hooks/useDepositionById.ts index d65d57e56..7c11ebb6a 100644 --- a/frontend/packages/data-portal/app/hooks/useDepositionById.ts +++ b/frontend/packages/data-portal/app/hooks/useDepositionById.ts @@ -12,7 +12,6 @@ import { GetDepositionAnnotationsForDatasetsQuery, GetDepositionByIdV2Query, type GetDepositionTomogramsQuery, - PerformVoodooQuery, GetAnnotationsForRunAndDepositionQuery, } from 'app/__generated_v2__/graphql' import { METHOD_TYPE_ORDER } from 'app/constants/methodTypes' @@ -34,7 +33,6 @@ export function useDepositionById() { v2, annotations, tomograms, - voodooData, datasetsViaTomograms, datasetsViaAnnotationShapes, runCountsForDepositionAnnotations, @@ -45,7 +43,6 @@ export function useDepositionById() { v2: GetDepositionByIdV2Query annotations?: GetDepositionAnnotationsQuery tomograms?: GetDepositionTomogramsQuery - voodooData: PerformVoodooQuery datasetsViaTomograms: GetDatasetsForDepositionViaTomogramsQuery datasetsViaAnnotationShapes: GetDatasetsForDepositionViaAnnotationShapesQuery runCountsForDepositionAnnotations: GetDepositionAnnoRunCountsForDatasetsQuery @@ -54,13 +51,14 @@ export function useDepositionById() { annotationShapesForDatasets: GetDepositionAnnotationsForDatasetsQuery }>() - console.log("voodooData", voodooData); // REMOVE + // BEGIN VINCENT_WORK, giant block of example query outputs, definitely not for deploy! console.log("datasetsViaTomograms", datasetsViaTomograms); // REMOVE console.log("datasetsViaAnnotationShapes", datasetsViaAnnotationShapes); // REMOVE console.log("runCountsForDepositionAnnotations", runCountsForDepositionAnnotations); // REMOVE console.log("runsAnnoForDepositionInDataset", runsAnnoForDepositionInDataset); // REMOVE console.log("annotationsForRunInDeposition", annotationsForRunInDeposition); // REMOVE console.log("annotationShapesForDatasets", annotationShapesForDatasets); // REMOVE + // END VINCENT_WORK const annotationMethods: AnnotationMethodMetadata[] = useMemo(() => { const annotationMethodToMetadata = new Map< diff --git a/frontend/packages/data-portal/app/routes/depositions.$id.tsx b/frontend/packages/data-portal/app/routes/depositions.$id.tsx index 1ca1653e4..9d0e97636 100644 --- a/frontend/packages/data-portal/app/routes/depositions.$id.tsx +++ b/frontend/packages/data-portal/app/routes/depositions.$id.tsx @@ -25,7 +25,6 @@ import { getDepositionAnnotationsForDatasets, } from 'app/graphql/getDepositionAnnotationsV2.server' import { getDepositionByIdV2 } from 'app/graphql/getDepositionByIdV2.server' -import {getVoodoo} from 'app/graphql/getVoodooExperimentV2.server' import { getDatasetsForDepositionViaTomograms, getDatasetsForDepositionViaAnnotationShapes, @@ -48,7 +47,6 @@ import { getFeatureFlag, useFeatureFlag } from 'app/utils/featureFlags' import { shouldRevalidatePage } from 'app/utils/revalidate' export async function loader({ params, request }: LoaderFunctionArgs) { - console.log("HELLO VOODOO FROM DEPOSITION LOADER"); // REMOVE const url = new URL(request.url) const id = params.id ? +params.id : NaN @@ -79,15 +77,7 @@ export async function loader({ params, request }: LoaderFunctionArgs) { params: url.searchParams, }) - // VOODOO Begin Vincent work, giant block of example query usage, not for real use! - const voodooResponse = await getVoodoo({ - client, - id, - }) - console.log("voodooResponse", voodooResponse); // REMOVE - console.log("voodooResponse.data.depositions", voodooResponse.data.depositions); // REMOVE - const voodooData = voodooResponse.data; - + // BEGIN VINCENT_WORK, giant block of example query usage, not for real use! const { data: datasetsViaTomograms } = await getDatasetsForDepositionViaTomograms({ client, depositionId: id, @@ -129,10 +119,9 @@ export async function loader({ params, request }: LoaderFunctionArgs) { client, depositionId: id, runId: EXAMPLE_RUN_ID, - page: 1, // VOODOO go back to 1! + page: 1, }) - // MANUALLY SET the following array based on deposition you are dev-ing against. // Here as a rough example of how user interaction would go. For deposition id 10314 // it has two datasets of id 10301 and 10302, so we choose some subset of those. @@ -143,7 +132,7 @@ export async function loader({ params, request }: LoaderFunctionArgs) { datasetIds: EXAMPLE_FILTERED_DATASET_IDS, page: 1, }) - // END VOODOO End Vincent work for requests to GraphQL + // END VINCENT_WORK for requests to GraphQL // There is more Vincent stuff put in to the response and the use hook if (responseV2.depositions.length === 0) { @@ -197,8 +186,6 @@ export async function loader({ params, request }: LoaderFunctionArgs) { v2: responseV2, annotations: data && 'annotationShapes' in data ? data : undefined, tomograms: data && 'tomograms' in data ? data : undefined, - // VOODOO below this line is Vincent demo stuff - voodooData: voodooData, datasetsViaTomograms, datasetsViaAnnotationShapes, runCountsForDepositionAnnotations,