From d8ce36e77f6af461dc91f22618fc3e6265c5ed54 Mon Sep 17 00:00:00 2001 From: Theodore Chang <theodore.chang@physik.hu-berlin.de> Date: Wed, 21 Aug 2024 09:39:43 +0000 Subject: [PATCH] Resolve "Extending published datasets blocked" --- nomad/metainfo/data_type.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/nomad/metainfo/data_type.py b/nomad/metainfo/data_type.py index 282a0dda20..facd79daf6 100644 --- a/nomad/metainfo/data_type.py +++ b/nomad/metainfo/data_type.py @@ -988,9 +988,16 @@ class Enum(NonPrimitive): return len(self._list) def _validate_value(self, value: str): - if value not in self: - raise ValueError(f'{value} is not a value of this enumeration.') - return value + if value in self: + return value + + # this is to account for the faulty values that exist in the database + # the faulty values are the ones look like `enumClass.enumValue` + # that are generated by calling `str()` on the enum fields + if (new_value := value.split('.')[-1]) in self: + return new_value + + raise ValueError(f'{value} is not a value of this enumeration.') def set_description(self, value: str, description: str): self._descriptions[self._validate_value(value)] = description -- GitLab