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

Add explicit range information to all classes & slots #40

Merged
merged 4 commits into from
Jan 9, 2025
Merged

Conversation

dalito
Copy link
Member

@dalito dalito commented Jan 9, 2025

This PR removes default_range: string and adds explicit add range information to all classes/slots.

This also marks still missing class_uri, slot_uri, meaning as todos (related to #19).

Closes #31

@dalito dalito added the enhancement New feature or request label Jan 9, 2025
@dalito dalito self-assigned this Jan 9, 2025
@dalito dalito added this to the 1.0.0 milestone Jan 9, 2025
This also marks missing class_uri, slot_uri,, meaning as todos.
@dalito
Copy link
Member Author

dalito commented Jan 9, 2025

The action failure is due to problems of Python <3.11 with datetime.fromisoformat("2024-02-19T00:00:00Z"). This is a known issue linkml/linkml#629

Also LinkML runtime has a bug preventing dumping json (specifically to serialise datetime). Running py examples\example_p1_pydantic.py gives this traceback:

Traceback (most recent call last):
  File "C:\Users\dlinke\MyProg_local\gh-nfdi4cat\pid4cat-model\examples\example_p1_pydantic.py", line 83, in <module>
    print(json_dumper.dumps(p1))
          ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\dlinke\MyProg_local\gh-nfdi4cat\pid4cat-model\.venv\Lib\site-packages\linkml_runtime\dumpers\json_dumper.py", line 64, in dumps
    return json.dumps(as_json_object(element, contexts, inject_type=inject_type),
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\dev\Python312\Lib\json\__init__.py", line 238, in dumps
    **kw).encode(obj)
          ^^^^^^^^^^^
  File "C:\dev\Python312\Lib\json\encoder.py", line 202, in encode
    chunks = list(chunks)
             ^^^^^^^^^^^^
  File "C:\dev\Python312\Lib\json\encoder.py", line 432, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "C:\dev\Python312\Lib\json\encoder.py", line 406, in _iterencode_dict
    yield from chunks
  File "C:\dev\Python312\Lib\json\encoder.py", line 326, in _iterencode_list
    yield from chunks
  File "C:\dev\Python312\Lib\json\encoder.py", line 406, in _iterencode_dict
    yield from chunks
  File "C:\dev\Python312\Lib\json\encoder.py", line 439, in _iterencode
    o = _default(o)
        ^^^^^^^^^^^
  File "C:\Users\dlinke\MyProg_local\gh-nfdi4cat\pid4cat-model\.venv\Lib\site-packages\linkml_runtime\dumpers\json_dumper.py", line 61, in default
    return json.JSONDecoder().decode(o)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\dev\Python312\Lib\json\decoder.py", line 338, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
                                      ^^^^^^^^
TypeError: expected string or bytes-like object, got 'datetime.datetime'

The example that uses the Python dataclasses works without errors py examples\example_p1_dataclasses.py.

I'll create an issue in the LinkML repo but merge this PR nevertheless.

@dalito dalito merged commit cac1341 into main Jan 9, 2025
2 of 4 checks passed
@dalito dalito deleted the issue31-ranges branch January 9, 2025 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Review/complete type information
1 participant