schema-automator icon indicating copy to clipboard operation
schema-automator copied to clipboard

Error parsing linkml schema with schema annotator if linkml schema contains an Enum which used `reachable_from` attribute.

Open proccaserra opened this issue 1 year ago • 0 comments

Describe the bug Error parsing linkml schema with schema annotator if linkml schema contains an Enum which used reachable_from attribute.

To Reproduce create a linkml schema with a dynamic enum using reachable_from, as in:

enums:
  NeuronTypeEnum:
    reachable_from:
      source_ontology: obo:cl

then, try invoking the enrich method over a schema_annotator instance, using a local ontology, as in:

oi = get_adapter("sparql:../resources/my_favourite_ontology.owl")
sa = SchemaAnnotator(ontology_implementation=oi)

schema = sa.enrich("test_schema_with_dynamic_enum_reachable_from.yaml")

Expected behavior loading the linkml schema should not fail, but currently getting the following error with linkml 1.8.3:

ValueError:  Unknown argument: ontology_source = 'local_resource:valueset'

stack trace:

File ~/venv/lib/python3.9/site-packages/linkml_runtime/linkml_model/meta.py:992, in EnumDefinition.__post_init__(self, *_, **kwargs)
    989 self.inherits = [v if isinstance(v, EnumDefinitionName) else EnumDefinitionName(v) for v in self.inherits]
    991 if self.reachable_from is not None and not isinstance(self.reachable_from, ReachabilityQuery):
--> 992     self.reachable_from = ReachabilityQuery(**as_dict(self.reachable_from))
    994 if self.matches is not None and not isinstance(self.matches, MatchQuery):
    995     self.matches = MatchQuery(**as_dict(self.matches))
File <string>:9, in __init__(self, source_ontology, source_nodes, relationship_types, is_direct, include_self, traverse_up, **_kwargs)

File ~/venv/lib/python3.9/site-packages/linkml_runtime/linkml_model/meta.py:1256, in ReachabilityQuery.__post_init__(self, *_, **kwargs)
   1253 if self.traverse_up is not None and not isinstance(self.traverse_up, Bool):
   1254     self.traverse_up = Bool(self.traverse_up)
-> 1256 super().__post_init__(**kwargs)

File ~/venv/lib/python3.9/site-packages/linkml_runtime/utils/yamlutils.py:56, in YAMLRoot.__post_init__(self, *args, **kwargs)
     54     v = repr(kwargs[k])[:40].replace('\n', '\\n')
     55     messages.append(f"{TypedNode.yaml_loc(k)} Unknown argument: {k} = {v}")
---> 56 raise ValueError('\n'.join(messages))

proccaserra avatar Oct 22 '24 17:10 proccaserra