Skip to content

Commit

Permalink
Austenem/CAT-966 Refactor ingest metadata (#3657)
Browse files Browse the repository at this point in the history
* update metadata calls

* add changelog
  • Loading branch information
austenem authored Jan 6, 2025
1 parent 50de222 commit 1eee491
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-refactor-ingest-metadata.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Update portal to account for refactored metadata from search api.
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ function AnalysisDetailsAccordion() {
}

const {
metadata: { dag_provenance_list },
ingest_metadata: { dag_provenance_list },
protocol_url,
} = dataset;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type ProcessedDatasetDetails = ProcessedDatasetInfo &
| 'created_timestamp'
| 'published_timestamp'
| 'last_modified_timestamp'
| 'ingest_metadata'
| 'metadata'
| 'protocol_url' // TODO: This is present for non-dataset entities, but not for datasets.
| 'dataset_type'
Expand Down Expand Up @@ -48,8 +49,8 @@ export function useProcessedDatasetDetails(uuid: string) {
'created_timestamp',
'published_timestamp',
'last_modified_timestamp',
'metadata.dag_provenance_list',
'metadata.metadata',
'ingest_metadata.dag_provenance_list',
'metadata',
'protocol_url',
'dataset_type',
'creation_action',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function usePipelineInfo(): PipelineInfo {
if (!isDataset(entity)) {
return defaultPipeline;
}
const dagList = entity.metadata.dag_provenance_list ?? [];
const dagList = entity.ingest_metadata.dag_provenance_list ?? [];
// Iterate over the list of DAGs and extract the latest origin and name
const pipelineInfo = dagList.reduce<PipelineInfo>(processDagList, defaultPipeline);
return pipelineInfo;
Expand Down
2 changes: 1 addition & 1 deletion context/app/static/js/components/search/Results/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const paths = {
dataset: {
donor: `donor.${donorMetadataPath}`,
sample: `source_samples.${sampleMetadataPath}`,
dataset: 'metadata.metadata',
dataset: 'metadata',
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const paths = {
dataset: {
donor: `donor.${donorMetadataPath}`,
sample: `source_samples.${sampleMetdataPath}`,
dataset: 'metadata.metadata',
dataset: 'metadata',
},
};

Expand Down
3 changes: 2 additions & 1 deletion context/app/static/js/components/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ export interface Entity {
donor: Donor;
descendant_counts: { entity_type: Record<string, number> };
descendant_ids: string[];
metadata: {
ingest_metadata: {
dag_provenance_list: DagProvenanceType[];
[key: string]: unknown;
};
metadata: Record<string, unknown>;
/** @deprecated Use `descendant_ids` and `useEntitiesData` instead */
descendants: Entity[];
group_name: string;
Expand Down
6 changes: 3 additions & 3 deletions context/app/static/js/helpers/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import { get } from './nodash';

const donorMetadataPath = 'mapped_metadata';
const sampleMetadataPath = 'metadata';
const sampleOrDatasetMetadataPath = 'metadata';

type ESEntityTypesWithIcons = Extract<ESEntityType, 'Donor' | 'Sample' | 'Dataset'>;

Expand All @@ -20,11 +20,11 @@ const paths: Record<ESEntityTypesWithIcons, Partial<Record<ESEntityType, string>
},
Sample: {
Donor: `donor.${donorMetadataPath}`,
Sample: sampleMetadataPath,
Sample: sampleOrDatasetMetadataPath,
},
Dataset: {
Donor: `donor.${donorMetadataPath}`,
Dataset: 'metadata.metadata',
Dataset: sampleOrDatasetMetadataPath,
},
};

Expand Down
5 changes: 3 additions & 2 deletions context/app/static/js/pages/Dataset/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export type ProcessedDatasetInfo = Pick<
| 'files'
| 'pipeline'
| 'status'
| 'ingest_metadata'
| 'metadata'
| 'creation_action'
| 'created_timestamp'
Expand Down Expand Up @@ -164,13 +165,13 @@ function getProcessedDatasetSection({
dataset: ProcessedDatasetInfo & { label: string };
hasConf?: boolean;
}) {
const { files, metadata, visualization, creation_action, contributors } = dataset;
const { files, ingest_metadata, visualization, creation_action, contributors } = dataset;

const shouldDisplaySection = {
summary: true,
visualization: visualization || conf,
files: Boolean(files?.length),
analysis: Boolean(metadata?.dag_provenance_list),
analysis: Boolean(ingest_metadata?.dag_provenance_list),
attribution: creation_action !== 'Central Process' && Boolean(contributors?.length),
};

Expand Down
10 changes: 5 additions & 5 deletions context/app/static/js/pages/search/DevSearch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,20 @@ function DevSearch() {
'Assay Types': [
listFilter('data_types', 'data_types'),
listFilter('mapped_data_types', 'mapped_data_types'),
listFilter('metadata.metadata.assay_category', 'assay_category'),
listFilter('metadata.metadata.assay_type', 'assay_type'),
listFilter('metadata.assay_category', 'assay_category'),
listFilter('metadata.assay_type', 'assay_type'),
checkboxFilter('is_derived', 'Is derived?', BoolMust(TermQuery('processing.keyword', 'processed'))),
checkboxFilter('is_raw', 'Is raw?', BoolMust(TermQuery('processing.keyword', 'raw'))),
hierarchicalFilter({
fields: {
parent: { id: 'metadata.metadata.analyte_class.keyword' },
parent: { id: 'metadata.analyte_class.keyword' },
child: { id: 'mapped_data_types.keyword' },
},
name: 'By analyte',
}),
hierarchicalFilter({
fields: {
parent: { id: 'metadata.metadata.assay_category.keyword' },
parent: { id: 'metadata.assay_category.keyword' },
child: { id: 'mapped_data_types.keyword' },
},
name: 'By category',
Expand All @@ -84,7 +84,7 @@ function DevSearch() {
checkboxFilter('has_substatus', 'Has substatus?', ExistsQuery('sub_status')),
checkboxFilter('is_living_donor', 'Is living donor?', ExistsQuery('metadata.living_donor_data')),
checkboxFilter('is_organ_donor', 'Is organ donor?', ExistsQuery('metadata.organ_donor_data')),
checkboxFilter('has_metadata', 'Has metadata?', ExistsQuery('metadata.metadata')),
checkboxFilter('has_metadata', 'Has metadata?', ExistsQuery('metadata')),
checkboxFilter('no_metadata', 'No metadata?', BoolMustNot(ExistsQuery('metadata.metadata'))),
checkboxFilter('has_files', 'Has files?', ExistsQuery('files')),
checkboxFilter('no_files', 'No files?', BoolMustNot(ExistsQuery('files'))),
Expand Down

0 comments on commit 1eee491

Please sign in to comment.