linkml / linkml

Linked Open Data Modeling Language
https://linkml.io/linkml
Other
309 stars 96 forks source link

lint vs. validate conflict: linter-recommended `EDAM.TOPIC` prefix fails validation but linter-disapproved `EDAM_TOPIC` works: #1512

Open cpauvert opened 1 year ago

cpauvert commented 1 year ago

Describe the bug Hello! I have an issue with the prefix for the EDAM ontology when using meaning in an enum. I followed the the convention in biolink with EDAM_TOPIC but this raised issue with validation (details below)

TL;DR:

The linter has a default configuration with regards to prefixmaps.

Should I follow the convention in biolink with EDAM_TOPIC and ignore the lint? because it seems that EDAM.TOPIC is converted to the python:

meaning=EDAM-TOPIC["3524"]

which causes a NameError: name 'EDAM' is not defined.

Best regards,

Details:

See more with prefix `EDAM_TOPIC`: linkml-lint FAIL ; linkml-validate PASS https://github.com/FAIR-MI/miiid-schema/blob/410aeb29afd3e81961ecc45a534f59077b651222/src/miiid_schema/schema/miiid_schema.yaml#LL17 ## Linting ```bash $ make lint poetry run linkml-lint src/miiid_schema/schema/miiid_schema.yaml /home/cpauvert/projects/linkml-projects/miiid-schema/src/miiid_schema/schema/miiid_schema.yaml warning Schema maps prefix 'EDAM_TOPIC' to namespace 'http://edamontology.org/topic_' instead of using prefix 'EDAM.TOPIC' (canonical_prefixes) ✖ Found 1 problem in 1 schema make: *** [Makefile:119: lint] Error 1 ``` ## Validation ```bash linkml-validate -s src/miiid_schema/schema/miiid_schema.yaml -C IntermicrobialInteraction \ src/data/examples/valid/IntermicrobialInteraction-pairwise.yaml # None ```
See more with prefix `EDAM.TOPIC`: linkml-lint PASS ; linkml-validate FAIL https://github.com/FAIR-MI/miiid-schema/blob/26460cd64769ddb87ac4a2f471ef7bb2c0f07fdd/src/miiid_schema/schema/miiid_schema.yaml#L17 ## Linting ```bash $ make lint poetry run linkml-lint src/miiid_schema/schema/miiid_schema.yaml ✓ No problems found ``` ## Validation ```bash linkml-validate -s src/miiid_schema/schema/miiid_schema.yaml -C IntermicrobialInteraction \ src/data/examples/valid/IntermicrobialInteraction-pairwise.yaml ``` ```python ERROR:root:Error compiling generated python code: name 'EDAM' is not defined Traceback (most recent call last): File "/home/cpauvert/.cache/pypoetry/virtualenvs/miiid-schema-6-7ZvLG3-py3.9/bin/linkml-validate", line 8, in sys.exit(cli()) File "/home/cpauvert/.cache/pypoetry/virtualenvs/miiid-schema-6-7ZvLG3-py3.9/lib/python3.9/site-packages/click/core.py", line 1130, in __call__ return self.main(*args, **kwargs) File "/home/cpauvert/.cache/pypoetry/virtualenvs/miiid-schema-6-7ZvLG3-py3.9/lib/python3.9/site-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) File "/home/cpauvert/.cache/pypoetry/virtualenvs/miiid-schema-6-7ZvLG3-py3.9/lib/python3.9/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, **ctx.params) File "/home/cpauvert/.cache/pypoetry/virtualenvs/miiid-schema-6-7ZvLG3-py3.9/lib/python3.9/site-packages/click/core.py", line 760, in invoke return __callback(*args, **kwargs) File "/home/cpauvert/.cache/pypoetry/virtualenvs/miiid-schema-6-7ZvLG3-py3.9/lib/python3.9/site-packages/linkml/validators/jsonschemavalidator.py", line 135, in cli python_module = PythonGenerator(schema).compile_module() File "/home/cpauvert/.cache/pypoetry/virtualenvs/miiid-schema-6-7ZvLG3-py3.9/lib/python3.9/site-packages/linkml/generators/pythongen.py", line 81, in compile_module raise e File "/home/cpauvert/.cache/pypoetry/virtualenvs/miiid-schema-6-7ZvLG3-py3.9/lib/python3.9/site-packages/linkml/generators/pythongen.py", line 77, in compile_module return compile_python(pycode) File "/home/cpauvert/.cache/pypoetry/virtualenvs/miiid-schema-6-7ZvLG3-py3.9/lib/python3.9/site-packages/linkml_runtime/utils/compile_python.py", line 47, in compile_python exec(spec, module.__dict__) File "test", line 169, in File "test", line 176, in MethodType NameError: name 'EDAM' is not defined ``` with one of the faulty line being probably: ```python simulation = PermissibleValue( text="simulation", description="Any type of biological computational model experiments", meaning=EDAM-TOPIC["3524"]) ```
cpauvert commented 1 year ago

This issues happened with linkml v1.5.5 and remains despite updating to 1.5.6.

sierra-moxon commented 1 year ago

Hi Charlie - thanks for the detailed issue; I’ll take a look.

sierra-moxon commented 1 year ago

@cpauvert - short answer, Biolink should be updated to use the edam.topic prefix following the conventions in bioregistry.io. but, this does mean linkml-validate will fail as you have demonstrated. I'm working on a couple of PRs to fix this behavior (see above).

cpauvert commented 1 year ago

Thanks @sierra-moxon for the heads-up, let me know how and when I should try out your edits!