From c32b5899a7bdbd0320fdd6f42055782c5b3dfc3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <h.tomwoerden@indiscale.com> Date: Sun, 24 Sep 2023 14:51:36 +0200 Subject: [PATCH] FIX: allow empty records in cfood --- CHANGELOG.md | 1 + src/caoscrawler/converters.py | 6 ++++++ unittests/test_parent_cfood.yml | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0670b374..accc64bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Removed ### ### Fixed ### +- Empty Records can now be created (https://gitlab.com/caosdb/caosdb-crawler/-/issues/27) ### Security ### diff --git a/src/caoscrawler/converters.py b/src/caoscrawler/converters.py index 4b1aa09e..930a08c1 100644 --- a/src/caoscrawler/converters.py +++ b/src/caoscrawler/converters.py @@ -235,6 +235,12 @@ def create_records(values: GeneralStore, records: RecordStore, def_records: dict keys_modified = [] for name, record in def_records.items(): + # If only a name was given (Like this: + # Experiment: + # ) set record to an empty dict / empty configuration + if record is None: + record = {} + role = "Record" # This allows us to create e.g. Files if "role" in record: diff --git a/unittests/test_parent_cfood.yml b/unittests/test_parent_cfood.yml index afb158b3..b8d0eaf5 100644 --- a/unittests/test_parent_cfood.yml +++ b/unittests/test_parent_cfood.yml @@ -10,7 +10,6 @@ data: match_name: '.*' records: Experiment: - name: "e" Projekt: parents: ["project"] name: "p" @@ -25,6 +24,7 @@ data: records: Experiment: parents: ["Exp"] + name: "e" Projekt: parents: ["Projekt"] Campaign: -- GitLab