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

Updating instances of ingest_metadata.metadata and ingest_metadata.fi… #1712

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
14 changes: 3 additions & 11 deletions src/components/custom/entities/Metadata.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function Metadata({data, metadata, mappedMetadata, groups}) {
if (!downloadRef.current) {
return
}

if (!downloadRef.current.href) {
// This is a bit of a hack to lazy download the provenance metadata
try {
Expand Down Expand Up @@ -161,7 +161,7 @@ function Metadata({data, metadata, mappedMetadata, groups}) {
}
// The dataset nav link
} else if (eq(ancestor.entity_type, cache.entities.dataset)) {
if (ancestor.ingest_metadata && Object.keys(ancestor.ingest_metadata).length && 'metadata' in ancestor.ingest_metadata) {
if (ancestor.metadata && Object.keys(ancestor.metadata).length > 0) {
return (
popoverCommon(index, 'dataset', ancestor)
)
Expand Down Expand Up @@ -208,18 +208,10 @@ function Metadata({data, metadata, mappedMetadata, groups}) {
tabPaneCommon('0', index, ancestor, metadata, undefined, groups)
)
}
} else if (!eq(ancestor.entity_type, cache.entities.dataset) && ancestor.metadata && Object.keys(ancestor.metadata).length > 0) {
// Handle mouse source and sample table
// Mice sources and all samples have their metadata inside "metadata"
} else if ( ancestor.metadata && Object.keys(ancestor.metadata).length > 0) {
return (
tabPaneCommon('1', index, ancestor, ancestor.metadata, ancestor.cedar_mapped_metadata)
)
} else if (ancestor.ingest_metadata && Object.keys(ancestor.ingest_metadata).length && 'metadata' in ancestor.ingest_metadata) {
// Handle dataset table
// Datasets have their metadata inside "metadata.metadata"
return (
tabPaneCommon('2', index, ancestor, ancestor.ingest_metadata.metadata, ancestor.cedar_mapped_metadata)
)
}
})}
</Tab.Content>
Expand Down
18 changes: 5 additions & 13 deletions src/components/custom/entities/dataset/FileTreeView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import InputGroup from 'react-bootstrap/InputGroup';
import {Tree} from 'primereact/tree';
import 'primeicons/primeicons.css';

export const FileTreeView = ({data, selection = {}, keys = {files: 'ingest_metadata', uuid: 'uuid'},
export const FileTreeView = ({data, selection = {}, keys = {files: 'files', uuid: 'uuid'},
loadDerived = true, treeViewOnly = false, className = '', filesClassName = '',
showQAButton = true, showDataProductButton = true, includeDescription= false,
showDownloadAllButton = false}) => {
Expand Down Expand Up @@ -45,14 +45,6 @@ export const FileTreeView = ({data, selection = {}, keys = {files: 'ingest_metad
return Array.isArray(obj) ? obj.length : Object.keys(obj).length
}

const getFiles = (data) => {
if (keys.files.contains('ingest_metadata')) {
return data?.ingest_metadata?.files
} else {
return data[keys.files]
}
}

useEffect( () => {
async function fetchData() {
await fetch_globus_filepath(data[keys.uuid]).then((globusData) => {
Expand All @@ -64,17 +56,17 @@ export const FileTreeView = ({data, selection = {}, keys = {files: 'ingest_metad
fetchData()

//Default to use files, otherwise wait until derivedDataset is populated
if (getFiles(data) && getLength(getFiles(data))) {
if (data[keys.files] && getLength(data[keys.files])) {
setHasData(true)
buildTree(data[keys.uuid], getFiles(data))
buildTree(data[keys.uuid], data[keys.files])
}
}, [])

useEffect(() => {
if (loadDerived) {
if (isPrimaryDataset && getFiles(derivedDataset) && getLength(getFiles(derivedDataset))) {
if (isPrimaryDataset && derivedDataset[keys.files] && getLength(derivedDataset[keys.files])) {
setHasData(true)
buildTree(derivedDataset[keys.uuid], getFiles(derivedDataset))
buildTree(derivedDataset[keys.uuid], derivedDataset[keys.files])
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/custom/vitessce/VignetteList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function VignetteList({ publication, ancillaryPublication }) {
const fetchVignettesData = async (uuid) => {
log.debug('==== Fetching vignettes data')
// ancillaryPublication should have a json config file
const fileName = ancillaryPublication.ingest_metadata.files[0].rel_path
const fileName = ancillaryPublication.files[0].rel_path
const path = `${uuid}/${fileName}`
const publicationAncillaryConfig = await getJSONFromAssetsEndpoint(path)

Expand Down
36 changes: 18 additions & 18 deletions src/config/search/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,60 +437,60 @@ export const SEARCH_METADATA = {
},

// Dataset
'ingest_metadata.metadata.acquisition_instrument_model': {
'metadata.acquisition_instrument_model': {
label: 'Acquisition Instrument Model',
type: 'value',
field: 'ingest_metadata.metadata.acquisition_instrument_model.keyword',
field: 'metadata.acquisition_instrument_model.keyword',
isExpanded: false,
filterType: 'any',
isFilterable: false,
facetType: 'term',
isAggregationActive: doesTermFilterContainValues('entity_type', ['Dataset']),
isFacetVisible: doesAggregationHaveBuckets('ingest_metadata.metadata.acquisition_instrument_model')
isFacetVisible: doesAggregationHaveBuckets('metadata.acquisition_instrument_model')
},
'ingest_metadata.metadata.acquisition_instrument_vendor': {
'metadata.acquisition_instrument_vendor': {
label: 'Acquisition Instrument Vendor',
type: 'value',
field: 'ingest_metadata.metadata.acquisition_instrument_vendor.keyword',
field: 'metadata.acquisition_instrument_vendor.keyword',
isExpanded: false,
filterType: 'any',
isFilterable: false,
facetType: 'term',
isAggregationActive: doesTermFilterContainValues('entity_type', ['Dataset']),
isFacetVisible: doesAggregationHaveBuckets('ingest_metadata.metadata.acquisition_instrument_vendor')
isFacetVisible: doesAggregationHaveBuckets('metadata.acquisition_instrument_vendor')
},
'ingest_metadata.metadata.analyte_class': {
'metadata.analyte_class': {
label: 'Analyte Class',
type: 'value',
field: 'ingest_metadata.metadata.analyte_class.keyword',
field: 'metadata.analyte_class.keyword',
isExpanded: false,
filterType: 'any',
isFilterable: false,
facetType: 'term',
isAggregationActive: doesTermFilterContainValues('entity_type', ['Dataset']),
isFacetVisible: doesAggregationHaveBuckets('ingest_metadata.metadata.analyte_class')
isFacetVisible: doesAggregationHaveBuckets('metadata.analyte_class')
},
'ingest_metadata.metadata.assay_category': {
'metadata.assay_category': {
label: 'Assay Category',
type: 'value',
field: 'ingest_metadata.metadata.assay_category.keyword',
field: 'metadata.assay_category.keyword',
isExpanded: false,
filterType: 'any',
isFilterable: false,
facetType: 'term',
isAggregationActive: doesTermFilterContainValues('entity_type', ['Dataset']),
isFacetVisible: doesAggregationHaveBuckets('ingest_metadata.metadata.assay_category')
isFacetVisible: doesAggregationHaveBuckets('metadata.assay_category')
},
'ingest_metadata.metadata.operator': {
'metadata.operator': {
label: 'Operator',
type: 'value',
field: 'ingest_metadata.metadata.operator.keyword',
field: 'metadata.operator.keyword',
isExpanded: false,
filterType: 'any',
isFilterable: false,
facetType: 'term',
isAggregationActive: doesTermFilterContainValues('entity_type', ['Dataset']),
isFacetVisible: doesAggregationHaveBuckets('ingest_metadata.metadata.operator')
isFacetVisible: doesAggregationHaveBuckets('metadata.operator')
},
},
disjunctiveFacets: [],
Expand Down Expand Up @@ -599,7 +599,7 @@ export const SEARCH_METADATA = {
entityType: 'dataset',
queryString: searchUIQueryString([
{field: 'entity_type', values: ['Dataset'], type: 'any'},
{field: 'ingest_metadata.metadata.analyte_class', values: ['Nucleic acid and protein'], type: 'any'}
{field: 'metadata.analyte_class', values: ['Nucleic acid and protein'], type: 'any'}
])
},
{
Expand All @@ -608,7 +608,7 @@ export const SEARCH_METADATA = {
entityType: 'dataset',
queryString: searchUIQueryString([
{field: 'entity_type', values: ['Dataset'], type: 'any'},
{field: 'ingest_metadata.metadata.analyte_class', values: ['RNA'], type: 'any'}
{field: 'metadata.analyte_class', values: ['RNA'], type: 'any'}
])
},
{
Expand All @@ -617,7 +617,7 @@ export const SEARCH_METADATA = {
entityType: 'dataset',
queryString: searchUIQueryString([
{field: 'entity_type', values: ['Dataset'], type: 'any'},
{field: 'ingest_metadata.metadata.assay_category', values: ['sequence'], type: 'any'}
{field: 'metadata.assay_category', values: ['sequence'], type: 'any'}
])
},
],
Expand Down
6 changes: 3 additions & 3 deletions src/context/DerivedContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,15 @@ export const DerivedProvider = ({children, showVitessceList, setShowVitessceList
if (datasetIs.processed(entity.creation_action)) {
const response = await fetch("/api/find?uuid=" + entity.uuid, getRequestHeaders())
const processed = await response.json()
if (processed.ingest_metadata && processed.ingest_metadata.files && processed.ingest_metadata.files.length) {
let dataProducts = filterFilesForDataProducts(processed.ingest_metadata.files, processed)
if (processed.files && processed.files.length) {
let dataProducts = filterFilesForDataProducts(processed.files, processed)
_files = _files.concat(dataProducts)
}
}
}
setDataProducts(_files)
} else {
_files = data.ingest_metadata?.files || []
_files = data?.files || []
setDataProducts(filterFilesForDataProducts(_files, data))

}
Expand Down
10 changes: 5 additions & 5 deletions src/pages/dataset.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ function ViewDataset() {
setCitationData(citation)

for (const ancestor of ancestry.ancestors) {
log.debug(ancestor)
if ((ancestor.metadata && Object.keys(ancestor.metadata).length) || (ancestor.ingest_metadata && Object.keys(ancestor.ingest_metadata) && 'metadata' in ancestor.ingest_metadata)) {
console.log(ancestor)
if ((ancestor.metadata && Object.keys(ancestor.metadata).length)) {
setAncestorHasMetadata(true)
break
}
Expand Down Expand Up @@ -202,7 +202,7 @@ function ViewDataset() {
data-bs-parent="#sidebar">Provenance</a>
</li>

{!!((data.ingest_metadata && Object.keys(data.ingest_metadata).length && 'metadata' in data.ingest_metadata) || ancestorHasMetadata) &&
{!!((data.metadata && Object.keys(data.metadata).length || ancestorHasMetadata)) &&
<li className="nav-item">
<a href="#Metadata"
className="nav-link"
Expand Down Expand Up @@ -275,10 +275,10 @@ function ViewDataset() {

{/*Metadata*/}
{/*Datasets have their metadata inside "metadata.metadata"*/}
{!!((data.ingest_metadata && Object.keys(data.ingest_metadata).length && 'metadata' in data.ingest_metadata) || ancestorHasMetadata) &&
{!!((data.metadata && Object.keys(data.metadata).length) || ancestorHasMetadata) &&
<Metadata
data={data}
metadata={data?.ingest_metadata?.metadata}
metadata={data?.metadata}
mappedMetadata={data?.cedar_mapped_metadata}
/>
}
Expand Down
4 changes: 2 additions & 2 deletions src/pages/publication.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ function ViewPublication() {
// get the most recent ancillary publication
ancillaryPublication = _data.descendants
.sort((a, b) => new Date(b.last_modified_timestamp) - new Date(a.last_modified_timestamp))
.find(d => d.dataset_type === 'Publication [ancillary]' && d.ingest_metadata?.files[0]?.rel_path)
.find(d => d.dataset_type === 'Publication [ancillary]' && d?.files[0]?.rel_path)
} else {
ancillaryPublication = _data.descendants
.find(d => d.dataset_type === 'Publication [ancillary]' && d.ingest_metadata?.files[0]?.rel_path)
.find(d => d.dataset_type === 'Publication [ancillary]' && d?.files[0]?.rel_path)
}

setAncillaryPublicationData(ancillaryPublication || {})
Expand Down