linkml / linkml-runtime

Runtime support for linkml generated models
https://linkml.io/linkml/
Creative Commons Zero v1.0 Universal
25 stars 23 forks source link

ValueError: Unrecognized prefix: <uri> #96

Closed noelmcloughlin closed 2 years ago

noelmcloughlin commented 2 years ago

I'm encountering an error with linkml-runtime which is ValueError: Unrecognized prefix: https://w3id.org/csolink/vocab/ .

I'm not sure why model with curie csolink:xxxx would generate this error. Any ideas?

prefixes:
  ACMBOOKS: 'https://dl.acm.org/action/doSearch?SeriesKey=acmbooks&AllField='  # acm Digital library books
  ACMJOURNALS: 'https://dl.acm.org/action/doSearch?ConceptID=118230&AllField='  # acm Digital library journals
  AML: 'https://w3id.org/i40/aml#'    # Automation machine learning
  astrovocab: 'https://www.asc-csa.gc.ca/eng/resources/vocabulary/view.asp?id='  # astronautics vocab
  csolink: 'https://w3id.org/csolink/vocab/'
  linkml: 'https://w3id.org/linkml/'
Run source env/bin/activate
Traceback (most recent call last):
  File "script/jekyllmarkdowngen.py", line 583, in <module>
    JekyllMarkdownGenerator(yamlfile=args.yaml, schema=args.yaml).serialize(directory=args.dir)
  File "/home/runner/work/csolink-model/csolink-model/env/lib/python3.7/site-packages/linkml/utils/generator.py", line 119, in serialize
    self.visit_subset(ss)
  File "/home/runner/work/csolink-model/csolink-model/env/lib/python3.7/site-packages/linkml/generators/markdowngen.py", line 265, in visit_subset
    curie = self.namespaces.uri_or_curie_for(self.namespaces._base, underscore(subset.name))
  File "/home/runner/work/csolink-model/csolink-model/env/lib/python3.7/site-packages/linkml_runtime/utils/namespaces.py", line 195, in uri_or_curie_for
    raise ValueError(f"Unrecognized prefix: {prefix}")
ValueError: Unrecognized prefix: https://w3id.org/csolink/vocab/
Error: Process completed with exit code 1.
cmungall commented 2 years ago

odd... but I suspect the issue is not with the prefixes themselves but in some other part of the schema - do you have the full yaml or link to a repo?

Aside: the full URIs for ACM and astrovocab are not great URIs from a LinkedData perspective. It won't do any harm just to get up and running this was but you may want to look at strategies for making PURLs for these.

You may be interested in the https://bioregistry.io/ project - despite it's name it has many non-bio specific prefixes registered. The entire infrastructure is lightweight and could easily be cloned. But I would be in favor of just using it for non-bio prefixes, there is already precedent for this.

I wonder how much work it would be to scrape the astrovocab web pages and make a bona-fide skos or owl vocabulary from it (with the cooperation of the authors of course).

noelmcloughlin commented 2 years ago

Thanks, it is odd. I'll take ownership of this issue and try to find cause and report back.

Yes, some of my URI are not great for linked data. To be honest, I've been using prefixes as a bookmark since I found astrovocab recently (and UCO: https://github.com/ucoProject), and bunch of others.

I'll have a look at bioregistry.io also. I'm seeking collaborators to curate a meta model, but nothing is published yet, just experiments and discovery on my part.

cmungall commented 2 years ago

OK, I have seen this error myself, and I believe it to be caused by a particular constellation of rdflib verisons, investigating, cc @hsolbrig

cmungall commented 2 years ago

Try it with linkml 1.1.15 - this release is more defensive against some of the nuanced changes between rdflib5 and 6

noelmcloughlin commented 2 years ago

Thanks @cmungall , this appears to be fixed in linkml 1.1.15 by https://github.com/linkml/linkml-runtime/pull/99 so closing.