Skip to content

Commit

Permalink
extra metadata dict, initialized inside from_owl_uri
Browse files Browse the repository at this point in the history
  • Loading branch information
burnout87 committed Jul 8, 2024
1 parent e8f8082 commit aa0081a
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions cdci_data_analysis/analysis/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ def __init__(self,
allowed_values=None,
min_value = None,
max_value = None,

extra_metadata=None,
**kwargs
):

Expand Down Expand Up @@ -261,6 +263,7 @@ def __init__(self,
self._max_value = max_value
self._bound_units = self.units
self.value = value
self.extra_metadata = extra_metadata


self._arg_list = [self.name]
Expand Down Expand Up @@ -463,6 +466,8 @@ def reprJSONifiable(self):
restrictions['schema'] = self.schema
if restrictions:
reprjson[0]['restrictions'] = restrictions
if getattr(self, 'extra_metadata', None) is not None:
reprjson[0]['extra_metadata'] = self.extra_metadata
if getattr(self, 'owl_uris', None):
if isinstance(self.owl_uris, str):
reprjson[0]['owl_uri'] = [ self.owl_uris ]
Expand Down Expand Up @@ -514,13 +519,16 @@ def from_owl_uri(cls,
par_unit = onto.get_parameter_unit(owl_uri)
min_value, max_value = onto.get_limits(owl_uri)
allowed_values = onto.get_allowed_values(owl_uri)

label = onto.get_oda_label(owl_uri)

for owl_superclass_uri in parameter_hierarchy:
for python_subclass in subclasses_recursive(cls):
logger.debug("searching for class with owl_uri=%s, found %s", owl_superclass_uri, python_subclass)
if python_subclass.matches_owl_uri(owl_superclass_uri):
logger.info("will construct %s by owl_uri %s", python_subclass, owl_superclass_uri)
call_kwargs = {}
call_kwargs = {'extra_metadata': {}}
if label is not None:
call_kwargs['extra_metadata']['label'] = label
call_signature = signature(python_subclass)
var_kw_signature = call_parameter.VAR_KEYWORD in [x.kind for x in call_signature.parameters.values()]

Expand Down Expand Up @@ -566,15 +574,16 @@ def from_owl_uri(cls,
class String(Parameter):
owl_uris = ("http://www.w3.org/2001/XMLSchema#str", "http://odahub.io/ontology#String")

def __init__(self, value=None, name_format='str', name=None, allowed_values = None):
def __init__(self, value=None, name_format='str', name=None, allowed_values = None, extra_metadata = None):

_allowed_units = ['str']
super().__init__(value=value,
units=name_format,
check_value=self.check_name_value,
name=name,
allowed_units=_allowed_units,
allowed_values=allowed_values)
allowed_values=allowed_values,
extra_metadata=extra_metadata)

@staticmethod
def check_name_value(value, units=None, name=None, par_format=None):
Expand Down

0 comments on commit aa0081a

Please sign in to comment.