From d4327eb17efde84df442da0e11e9f70eeb218f48 Mon Sep 17 00:00:00 2001 From: Alexander Schlemmer <alexander@mail-schlemmer.de> Date: Wed, 31 May 2023 15:39:56 +0200 Subject: [PATCH] ENH: it is now possible to deserialize records using the high level api without giving parents or metadata --- src/caosdb/high_level_api.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/caosdb/high_level_api.py b/src/caosdb/high_level_api.py index 427a095a..005a20bb 100644 --- a/src/caosdb/high_level_api.py +++ b/src/caosdb/high_level_api.py @@ -629,18 +629,20 @@ class CaosDBPythonEntity(object): else: entity = CaosDBPythonRecord() - for parent in serialization["parents"]: - if "unresolved" in parent: - id = None - name = None - if "id" in parent: - id = parent["id"] - if "name" in parent: - name = parent["name"] - entity.add_parent(CaosDBPythonUnresolvedParent( - id=id, name=name)) - else: - raise NotImplementedError() + if "parents" in serialization: + for parent in serialization["parents"]: + if "unresolved" in parent: + id = None + name = None + if "id" in parent: + id = parent["id"] + if "name" in parent: + name = parent["name"] + entity.add_parent(CaosDBPythonUnresolvedParent( + id=id, name=name)) + else: + raise NotImplementedError( + "Currently, only unresolved parents can be deserialized.") for baseprop in ("name", "id", "description", "version"): if baseprop in serialization: @@ -673,7 +675,8 @@ class CaosDBPythonEntity(object): if f.name in metadata: propmeta.__setattr__(f.name, metadata[f.name]) else: - raise NotImplementedError() + pass + # raise NotImplementedError() return entity -- GitLab