From 7ae64a376d290e32eba65efb1483ce61d53a2aee Mon Sep 17 00:00:00 2001 From: Gaurav Vaidya Date: Mon, 4 Oct 2021 21:08:31 -0400 Subject: [PATCH] Implement Shahim's suggestion to write a "NULL" for empty enums. See #85. --- .../sheet2linkml/source/gsheetmodel/enum.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/vendor/sheet2linkml/sheet2linkml/source/gsheetmodel/enum.py b/vendor/sheet2linkml/sheet2linkml/source/gsheetmodel/enum.py index 413d61d3d..87b189049 100644 --- a/vendor/sheet2linkml/sheet2linkml/source/gsheetmodel/enum.py +++ b/vendor/sheet2linkml/sheet2linkml/source/gsheetmodel/enum.py @@ -209,11 +209,22 @@ def as_linkml(self, root_uri) -> EnumDefinition: self.mappings.set_mappings_on_element(enum) # Now generate LinkML for all of the values. - enum.permissible_values = { + pv_values = { str(enum_value.name): enum_value.as_linkml(root_uri) for enum_value in self.values } + # If we have no permissible values, then define a single PV named "null" + # (see https://github.com/cancerDHC/ccdhmodel/issues/85 for details) + if len(pv_values) == 0: + pv_values = { + 'NULL': PermissibleValue( + text='NULL' + ) + } + + enum.permissible_values = pv_values + return enum