biolink / biolinkml

DEPRECATED: replaced by linkml
https://github.com/linkml/linkml
Creative Commons Zero v1.0 Universal
23 stars 12 forks source link

gen-owl error(s) #333

Closed dwinston closed 3 years ago

dwinston commented 3 years ago

For example, trying gen-owl schema/prov.yaml for this file raises

Traceback (most recent call last):
  File "/opt/miniconda3/envs/nmdc/bin/gen-owl", line 8, in <module>
    sys.exit(cli())
  File "/opt/miniconda3/envs/nmdc/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/opt/miniconda3/envs/nmdc/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/opt/miniconda3/envs/nmdc/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/miniconda3/envs/nmdc/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/opt/miniconda3/envs/nmdc/lib/python3.8/site-packages/biolinkml/generators/owlgen.py", line 298, in cli
    print(OwlSchemaGenerator(yamlfile, **kwargs).serialize(**kwargs))
  File "/opt/miniconda3/envs/nmdc/lib/python3.8/site-packages/biolinkml/generators/owlgen.py", line 34, in __init__
    super().__init__(schema, **kwargs)
  File "/opt/miniconda3/envs/nmdc/lib/python3.8/site-packages/biolinkml/utils/generator.py", line 92, in __init__
    loader.resolve()
  File "/opt/miniconda3/envs/nmdc/lib/python3.8/site-packages/biolinkml/utils/schemaloader.py", line 156, in resolve
    self.raise_value_error(f'Class "{cls.name}" - unknown slot: "{slotname}"', slotname)
  File "/opt/miniconda3/envs/nmdc/lib/python3.8/site-packages/biolinkml/utils/schemaloader.py", line 679, in raise_value_error
    raise ValueError(f'{TypedNode.yaml_loc(loc_str)} {error}')
ValueError: File "/Users/dwinston/repos/nmdc/nmdc-metadata/schema/prov.yaml", line 28, col 9:  Class "activity" - unknown slot: "id"

and a larger example, gen-owl schema/nmdc.yaml for this file raises

Traceback (most recent call last):
  File "/opt/miniconda3/envs/nmdc/bin/gen-owl", line 8, in <module>
    sys.exit(cli())
  File "/opt/miniconda3/envs/nmdc/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/opt/miniconda3/envs/nmdc/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/opt/miniconda3/envs/nmdc/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/miniconda3/envs/nmdc/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/opt/miniconda3/envs/nmdc/lib/python3.8/site-packages/biolinkml/generators/owlgen.py", line 298, in cli
    print(OwlSchemaGenerator(yamlfile, **kwargs).serialize(**kwargs))
  File "/opt/miniconda3/envs/nmdc/lib/python3.8/site-packages/biolinkml/generators/owlgen.py", line 39, in __init__
    SchemaLoader(METAMODEL_YAML_URI, base_dir=META_BASE_URI, importmap=kwargs.get('importmap', None),
  File "/opt/miniconda3/envs/nmdc/lib/python3.8/site-packages/biolinkml/utils/schemaloader.py", line 50, in __init__
    self.schema = load_raw_schema(data, base_dir=base_dir, merge_modules=mergeimports,
  File "/opt/miniconda3/envs/nmdc/lib/python3.8/site-packages/biolinkml/utils/rawloader.py", line 66, in load_raw_schema
    return load_raw_schema(response, fname, response.info()['Last-Modified'],
  File "/opt/miniconda3/envs/nmdc/lib/python3.8/site-packages/biolinkml/utils/rawloader.py", line 150, in load_raw_schema
    for sname, sdef in {k: SchemaDefinition(name=k, **v) for k, v in schemadefs.items()}.items():
  File "/opt/miniconda3/envs/nmdc/lib/python3.8/site-packages/biolinkml/utils/rawloader.py", line 150, in <dictcomp>
    for sname, sdef in {k: SchemaDefinition(name=k, **v) for k, v in schemadefs.items()}.items():
  File "<string>", line 49, in __init__
  File "/opt/miniconda3/envs/nmdc/lib/python3.8/site-packages/biolinkml/meta.py", line 399, in __post_init__
    super().__post_init__(**kwargs)
  File "/opt/miniconda3/envs/nmdc/lib/python3.8/site-packages/biolinkml/meta.py", line 272, in __post_init__
    super().__post_init__(**kwargs)
  File "/opt/miniconda3/envs/nmdc/lib/python3.8/site-packages/biolinkml/utils/yamlutils.py", line 32, in __post_init__
    raise ValueError('\n'.join(messages))
ValueError: File "<file>", line 1130, col 1:  Unknown argument: enums = {'pv_formula_options': {'description': '

I am using python 3.8 and biolinkml==1.6.1 via pip install. I'm not sure how to troubleshoot. Thanks @cmungall for suggesting I note the issue here to track.

hsolbrig commented 3 years ago

On it.

hsolbrig commented 3 years ago

The first error message (at the bottom): is trying to say id is not a defined slot. We clearly need to remove the stack cruft from the actual message itself. To get this to parse, you will need to add id, name and type to the slot definitions.

I would propose that I go ahead complete the prov.yaml schema as a bit of a hint on where you are going. Note, in particular, that we now have a syntactic shortcut that allows slots to be defined directly under classes.

Similarly, on the second error message (which I'm getting from line 185 in annotation.yaml), it is whining because there are two identifiers declared (id and entity_inchi) for the class. The current BiolinkML implementation only supports single keys.

Will post a new issue to clean up the error messages. Also, would be happy to set up an online session to work through some of the issues

dwinston commented 3 years ago

Thanks for looking into this!

For the first error, I was hoping that perhaps the

imports:
  - biolinkml:types

section of prov.yaml was a signal that slot definitions for id et al. would be imported from another place or something? I am totally new to biolinkml -- my intuition there is from from foo import * in Python modules.

For the second error message, that makes a lot of sense. I wonder why that double-identifier error doesn't trigger when generating other formats (e.g. gen-jsonld), though.

I'm just trying to use the raw yaml and the generated html docs to get stuff done in the short term, but I'd be interested in working through issues with you at some point. Thanks!

cmungall commented 3 years ago

Thanks all!

@hsolbrig

The first error message (at the bottom): is trying to say id is not a defined slot. We clearly need to remove the stack cruft from the actual message itself. To get this to parse, you will need to add id, name and type to the slot definitions.

this is due to my poor modularization in prov. It uses id which is defined in core. however, prov imports core, rather than vice versa! this doesn't manifest when we use the nmdc module, as it imports both. But it's now clear that this first error is purely an nmdc schema issue, not linkml, thanks!

@dwinston

section of prov.yaml was a signal that slot definitions for id et al. would be imported from another place or something? I am totally new to biolinkml -- my intuition there is from from foo import * in Python modules.

your intuition is pretty much spot on, except that id is not defined in the metamodel, it's a field we declare in nmdc

@hsolbrig:

Similarly, on the second error message (which I'm getting from line 185 in annotation.yaml), it is whining because there are two identifiers declared (id and entity_inchi) for the class. The current BiolinkML implementation only supports single keys.

@wdduncan and @deepakunni3 fixed the inchi key issue independently (this was due to me using key incorrectly - more on key here: #211). @dwinston if you try again on master hopefully this vanishes, and we can close this ticket!

And yes, having more concise error reporting would have helped us spot the cause of error here!

dwinston commented 3 years ago

Thanks @cmungall and @hsolbrig ! gen-owl schema/{prov,core,nmdc}.yaml all work after moving id, name, and type slot definitions to prov.yaml (PR at microbiomedata/nmdc-metadata#222) (using biolinkml==1.7.0).

cmungall commented 3 years ago

thanks!