From bff2ba32ef7e2c64ff754ad371ce42cf5585e7a1 Mon Sep 17 00:00:00 2001 From: tcezard Date: Tue, 12 Sep 2023 14:51:19 +0100 Subject: [PATCH] Hack to remove the null values in external reference when pushing a curation object --- eva_submission/biosamples_submission.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/eva_submission/biosamples_submission.py b/eva_submission/biosamples_submission.py index ecb62a7..9565aaf 100644 --- a/eva_submission/biosamples_submission.py +++ b/eva_submission/biosamples_submission.py @@ -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 = [] @@ -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