Skip to content

Commit

Permalink
Hack to remove the null values in external reference when pushing a c…
Browse files Browse the repository at this point in the history
…uration object
  • Loading branch information
tcezard committed Sep 12, 2023
1 parent c65adb5 commit bff2ba3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions eva_submission/biosamples_submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,15 @@ def validate_in_bsd(self, samples_data):
def convert_sample_data_to_curation_object(self, future_sample):
"""Curation object can only change 3 attributes characteristics, externalReferences and relationships"""
current_sample = self.communicator.follows_link('samples', method='GET', join_url=future_sample.get('accession'))

#FIXME: Remove this hack when this i fixed on BioSample's side
# remove null values in externalReferences that causes crash when POSTing the curation object
if 'externalReferences' in current_sample:
current_sample['externalReferences'] = [
dict([(k, v) for k, v in external_ref.items() if v is not None])
for external_ref in current_sample['externalReferences']
]

curation_object = {}
attributes_pre = []
attributes_post = []
Expand Down Expand Up @@ -481,5 +490,14 @@ def retrieve_biosamples(self):
if 'externalReferences' not in sample_json:
sample_json['externalReferences'] = []
sample_json['externalReferences'].append({'url': eva_study_url})

# FIXME: Remove this hack when this i fixed on BioSample's side
# remove null values in externalReferences that causes crash when POSTing the curation object
if 'externalReferences' in sample_json:
sample_json['externalReferences'] = [
dict([(k, v) for k, v in external_ref.items() if v is not None])
for external_ref in sample_json['externalReferences']
]
biosample_objects.append(sample_json)

return biosample_objects

0 comments on commit bff2ba3

Please sign in to comment.