Skip to content

Commit

Permalink
Merge pull request #206 from sennetconsortium/maxsibilla/issue-169
Browse files Browse the repository at this point in the history
Maxsibilla/issue 169
  • Loading branch information
maxsibilla authored Nov 22, 2023
2 parents 88de8fd + 657757a commit 7143d84
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.17
1.2.18
2 changes: 1 addition & 1 deletion ingest-api-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ openapi: 3.0.0
info:
description: |
A RESTful web service exposing calls needed for the SenNet Data Sharing Portal.
version: 1.2.17
version: 1.2.18
title: SenNet Ingest API
contact:
name: SenNet Help Desk
Expand Down
11 changes: 9 additions & 2 deletions src/lib/file.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import csv
import os
import glob
import logging
from hubmap_commons import file_helper as commons_file_helper
from flask import current_app, request
Expand Down Expand Up @@ -87,7 +88,7 @@ def ln_err(error: str, row: int = None, column: str = None):
}


def files_exist(uuid, data_access_level, group_name):
def files_exist(uuid, data_access_level, group_name, metadata=False):
if not uuid or not data_access_level:
return False
if data_access_level == "public":
Expand All @@ -100,6 +101,12 @@ def files_exist(uuid, data_access_level, group_name):
absolute_path = commons_file_helper.ensureTrailingSlashURL(current_app.config['GLOBUS_PROTECTED_ENDPOINT_FILEPATH'] + '/' + group_name)
file_path = absolute_path + uuid
if os.path.exists(file_path) and os.path.isdir(file_path) and os.listdir(file_path):
return True
if not metadata:
return True
else:
if any(glob.glob(os.path.join(file_path, '**', '*metadata.tsv'), recursive=True)):
return True
else:
return False
else:
return False
8 changes: 5 additions & 3 deletions src/routes/entity_CRUD/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ def dataset_data_status():
"RETURN DISTINCT ds.uuid AS uuid, "
"COLLECT(DISTINCT dn.sennet_id) AS source_sennet_id, "
"COLLECT(DISTINCT dn.source_type) AS source_type, "
"COLLECT(DISTINCT dn.lab_source_id) AS source_lab_id, COALESCE(dn.metadata IS NOT NULL) AS has_metadata"
"COLLECT(DISTINCT dn.lab_source_id) AS source_lab_id, COALESCE(dn.metadata IS NOT NULL) AS has_donor_metadata"
)

descendant_datasets_query = (
Expand All @@ -643,7 +643,7 @@ def dataset_data_status():
displayed_fields = [
"sennet_id", "group_name", "status", "organ", "provider_experiment_id", "last_touch", "has_contacts",
"has_contributors", "data_types", "source_sennet_id", "source_lab_id",
"has_metadata", "descendant_datasets", "upload", "has_rui_info", "globus_url", "portal_url", "ingest_url",
"has_dataset_metadata", "has_donor_metadata", "descendant_datasets", "upload", "has_rui_info", "globus_url", "portal_url", "ingest_url",
"has_data", "organ_sennet_id"
]

Expand Down Expand Up @@ -677,7 +677,7 @@ def dataset_data_status():
output_dict[dataset['uuid']]['source_type'] = dataset['source_type']
# output_dict[dataset['uuid']]['source_submission_id'] = dataset['source_submission_id']
output_dict[dataset['uuid']]['source_lab_id'] = dataset['source_lab_id']
output_dict[dataset['uuid']]['has_metadata'] = dataset['has_metadata']
output_dict[dataset['uuid']]['has_donor_metadata'] = dataset['has_donor_metadata']
for dataset in descendant_datasets_result:
if output_dict.get(dataset['uuid']):
output_dict[dataset['uuid']]['descendant_datasets'] = dataset['descendant_datasets']
Expand Down Expand Up @@ -710,7 +710,9 @@ def dataset_data_status():
else:
dataset['is_primary'] = "false"
has_data = files_exist(dataset.get('uuid'), dataset.get('data_access_level'), dataset.get('group_name'))
has_dataset_metadata = files_exist(dataset.get('uuid'), dataset.get('data_access_level'), dataset.get('group_name'), metadata=True)
dataset['has_data'] = has_data
dataset['has_dataset_metadata'] = has_dataset_metadata

for prop in dataset:
if isinstance(dataset[prop], list):
Expand Down

0 comments on commit 7143d84

Please sign in to comment.