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

feat: add fileSize to asset downloads #1570

Merged
merged 6 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const GET_DATASET_BY_ID_QUERY_V2 = gql(`
lastModifiedDate
releaseDate
depositionDate

fileSize
# Dataset metadata
id
title
Expand Down
9 changes: 9 additions & 0 deletions frontend/packages/data-portal/app/graphql/getRunByIdDiffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,15 @@ export function logIfHasDiff(
},
],
},
numTotalSizeAnnotationFiles: {
aggregate: [
{
sum: {
fileSize: v1.annotation_files_aggregate_for_total.aggregate?.count,
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 here to satiate type-check, but doesn't really exist in V1 - let me know if there's a better way of doing it!

Copy link
Contributor

Choose a reason for hiding this comment

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

Could also just delete the field, like above where I delete a bunch of fields that aren't in V1!

},
},
],
},
tomogramsAggregate: {
aggregate: [
{
Expand Down
12 changes: 12 additions & 0 deletions frontend/packages/data-portal/app/graphql/getRunByIdV2.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const GET_RUN_BY_ID_QUERY_V2 = gql(`
cellTypeId
depositionDate
description
fileSize
gridPreparation
id
lastModifiedDate
Expand Down Expand Up @@ -223,6 +224,7 @@ const GET_RUN_BY_ID_QUERY_V2 = gql(`
format
httpsPath
s3Path
fileSize
}
}
}
Expand Down Expand Up @@ -294,6 +296,8 @@ const GET_RUN_BY_ID_QUERY_V2 = gql(`
}
ctfCorrected
fiducialAlignmentStatus
fileSizeMrc
fileSizeOmezarr
httpsMrcFile
id
isPortalStandard
Expand Down Expand Up @@ -404,6 +408,14 @@ const GET_RUN_BY_ID_QUERY_V2 = gql(`
}
}
numTotalSizeAnnotationFiles: annotationFilesAggregate(where: { annotationShape: { annotation: { runId: { _eq: $id }}}}) {
aggregate {
sum {
fileSize
}
}
}
# Tomogram counts:
tomogramsAggregate(where: { runId: { _eq: $id }}) {
aggregate {
Expand Down
29 changes: 0 additions & 29 deletions frontend/packages/data-portal/app/hooks/useFileSize.ts

This file was deleted.

2 changes: 2 additions & 0 deletions frontend/packages/data-portal/app/hooks/useRunById.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ export function useRunById() {
groundTruthCount:
v2.numFilteredGroundTruthAnnotationRows.aggregate?.[0].count ?? 0,
otherCount: v2.numFilteredOtherAnnotationRows.aggregate?.[0].count ?? 0,
totalSize:
v2.numTotalSizeAnnotationFiles?.aggregate?.[0].sum?.fileSize ?? 0,
}

const tomogramsCount = v2.tomogramsAggregate.aggregate?.[0].count ?? 0
Expand Down
28 changes: 0 additions & 28 deletions frontend/packages/data-portal/app/routes/api.file-size.ts

This file was deleted.

1 change: 1 addition & 0 deletions frontend/packages/data-portal/app/routes/datasets.$id.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export default function DatasetByIdPage() {
datasetId={dataset.id}
datasetTitle={dataset.title}
s3Path={dataset.s3Prefix}
fileSize={dataset.fileSize ?? undefined}
type="dataset"
/>
}
Expand Down
28 changes: 20 additions & 8 deletions frontend/packages/data-portal/app/routes/runs.$id.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { getRunById } from 'app/graphql/getRunById.server'
import { logIfHasDiff } from 'app/graphql/getRunByIdDiffer'
import { getRunByIdV2 } from 'app/graphql/getRunByIdV2.server'
import { useDownloadModalQueryParamState } from 'app/hooks/useDownloadModalQueryParamState'
import { useFileSize } from 'app/hooks/useFileSize'
import { useI18n } from 'app/hooks/useI18n'
import { useQueryParam } from 'app/hooks/useQueryParam'
import { useRunById } from 'app/hooks/useRunById'
Expand Down Expand Up @@ -133,15 +132,28 @@ export default function RunByIdPage() {
annotationShape.shapeType === objectShapeType,
)

const httpsPath = activeAnnotationShape
? activeAnnotationShape.annotationFiles.edges.find(
(file) => file.node.format === fileFormat,
)?.node.httpsPath
const activeFile = activeAnnotationShape?.annotationFiles.edges.find(
(file) => file.node.format === fileFormat,
)

const httpsPath = activeFile
? activeFile.node.httpsPath
: activeTomogram?.httpsMrcFile ?? undefined

const { data: fileSize } = useFileSize(httpsPath, {
enabled: fileFormat !== 'zarr',
})
const getFileSize = () => {
if (activeFile) {
return activeFile.node.fileSize ?? undefined
}
if (fileFormat === 'mrc') {
return activeTomogram?.fileSizeMrc ?? undefined
}
if (fileFormat === 'zarr') {
return activeTomogram?.fileSizeOmezarr ?? undefined
}
return annotationFilesAggregates.totalSize
}

const fileSize = getFileSize()

const [depositionId] = useQueryParam<string>(QueryParams.DepositionId)

Expand Down