linkml / linkml

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

Tests break due to `NameError: name 'PermissibleValue' is not defined` when importing linkml:datasets #1763

Open caufieldjh opened 7 months ago

caufieldjh commented 7 months ago

Describe the bug As part of Datasheets for Datasets schema development, we're trying to import the linkml datasets schema. Seems to work fine - no complaints from the linter and artifacts get built without issue. But running tests breaks when they try to import the datasets schema classes.

To reproduce See https://github.com/bridge2ai/data-sheets-schema/actions/runs/7130629593/job/19417444049

poetry run python -m unittest discover
E
======================================================================
ERROR: tests.test_data (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: tests.test_data
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/unittest/loader.py", line 436, in _find_test_path
    module = self._get_module_from_name(name)
  File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "/home/runner/work/data-sheets-schema/data-sheets-schema/tests/test_data.py", line 7, in <module>
    from data_sheets_schema.datamodel.data_sheets_schema import DatasetCollection
  File "/home/runner/work/data-sheets-schema/data-sheets-schema/src/data_sheets_schema/datamodel/__init__.py", line 1, in <module>
    from .data_sheets_schema import *
  File "/home/runner/work/data-sheets-schema/data-sheets-schema/src/data_sheets_schema/datamodel/data_sheets_schema.py", line 24, in <module>
    from linkml_runtime.linkml_model.datasets import DataPackage, DataPackageId, DataResource, DataResourceId, FormatEnum, TestRole
  File "/home/runner/.cache/pypoetry/virtualenvs/data-sheets-schema-qjM2JcdQ-py3.9/lib/python3.9/site-packages/linkml_runtime/linkml_model/datasets.py", line 301, in <module>
    class TestRole(EnumDefinitionImpl):
  File "/home/runner/.cache/pypoetry/virtualenvs/data-sheets-schema-qjM2JcdQ-py3.9/lib/python3.9/site-packages/linkml_runtime/linkml_model/datasets.py", line 303, in TestRole
    Example = PermissibleValue(text="Example")
NameError: name 'PermissibleValue' is not defined

Expected behavior

Should the PermissibleValue just be imported from the metamodel? I tried importing linkml:meta into the schema but that presents conflicts between meta and datasets.

Or should I not be using the datasets schema this way (i.e., I should copy relevant parts into the new schema)?

sujaypatil96 commented 2 months ago

Looks like all tests are passing now on data-sheets-schema? can this issue be closed @caufieldjh?

caufieldjh commented 2 months ago

They are passing because I used the workaround of copypasting what I needed from the datasets schema into the datasheets schema, bypassing the import entirely. I would still consider this issue open if there is an intent to support importing the dataset schema.