Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LinkML Doc Generator error messages are inconsistent when Range value is prefixed #139

Open
mahdanoura opened this issue Jul 5, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@mahdanoura
Copy link

mahdanoura commented Jul 5, 2024

Describe the bug
I use the following LinkML snippet, which imports hctl and wot_security as local LinkML yaml files.

imports:
  - linkml:types
  - hctl
  - wot_security
classes:
  Thing:
    tree_root: true
    class_uri: td:Thing
    attributes:
      securityDefinitions:
        description: >-
          A security scheme applied to a (set of) affordance(s).
        from_schema: td:hasSecurityConfiguration
        required: true
        multivalued: true
        any_of:
          - range: string
          - range: wot_security:SecuritySchemeType
      links:
        from_schema: td:hasLink
        description: >-
          Provides Web links to arbitrary resources that relate to the specified Thing Description.
        multivalued: true
        range: hctl:Link

I noticed LinkML does not like the prefixing to the imports for specifying the Range. However, the error messages produced are inconsistent. For range: hctl:Link I get the following error:
ValueError: File "thing_description.yaml", line 363, col 16 slot: thing__links - unrecognized range (hctl:Link)

However, for range: wot_security:SecuritySchemeType, the error message is completely vague:
AttributeError: 'NoneType' object has no attribute 'from_schema'

To Reproduce
My environment is as follows:

python = 3.11
linkml-runtime = 1.8.0rc2
linkml = 1.8.0rc2

Expected behavior
I expect the error messages for the same problem to be consistent and meaningful, because digging the issue becomes cumbersome.

Code snippets
I generate the documents using the python class as follows:

doc_generator = DocGenerator('resources/schemas/thing_description.yaml', mergeimports=False)
doc_generator.serialize(directory=str(DOCDIR))
@mahdanoura mahdanoura added the bug Something isn't working label Jul 5, 2024
@turbomam
Copy link
Collaborator

turbomam commented Jul 8, 2024

I agree that LinkML error messages can be confusing and inconsistent.

Is your work in a code repository? Can you share that?

One of the things I wondering about is whether your hctl and wot_security prefixes need to be defined in the schema file that contains the lines you included above.

@mahdanoura
Copy link
Author

mahdanoura commented Jul 9, 2024

The code is in this repo and the LinkML schemas are located in the schema directory.
The names I provide in the import statements correspond to the schema names and not their prefixes, otherwise those entities are not found. I appreciate the feedback. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants