-
Notifications
You must be signed in to change notification settings - Fork 35
feat: add language and datatype support when converting rdflib.terms.… #356
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
base: main
Are you sure you want to change the base?
Conversation
…Literal to JSON-LD
|
of course, this PR is broken if we consider that only However, it would still fix the missing Any thoughts ? |
|
@ticapix I have moved the work for this PR from the contributor fork to the linkml-runtime branch https://github.com/linkml/linkml-runtime/pull/new/add_rdf_lang_type_support . These branches will be lifted over in the merge to the mono-repo so you won't lose you work. You will need to open a new PR against the linkml monorepo after the move. I'd prefer to get this in but if we can't please open a new PR when you resume work. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The core changes in yamlutils.py to serialize langstrings looks solid. The biggest change needed is how the test is constructed. I gave my suggestion on how I would handle it, but it'd probably be good to check with people who have stronger opinions on how tests in here are presented.
| from jsonasobj2 import JsonObj, JsonObjTypes, as_dict, as_json, items | ||
| from rdflib import Graph, URIRef | ||
| from jsonasobj2 import JsonObj, as_json, as_dict, JsonObjTypes, items | ||
| import jsonasobj2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import is unused
| from typing import ( | ||
| Any, | ||
| ClassVar, | ||
| Dict, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since support for Python 3.8 was dropped earlier this year, these imports should be removed, and plain old dict and list should be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both of these entries should be removed-- html5lib should be added to the [dependencies] section in pyproject.toml.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about the strategy here to define a schema inline-- if this test were merged, the definition would potentially have to be kept up to date with changes in behavior of linkml runtime. (There's already one here, as dataclasses_init_fn_with_kwargs has been deprecated).
There's already a Person schema defined in tests. Can that be reused here to define a test case? (See these lines).
It might be good to add a new test case to that file instead of adding a new file here. (Although others may have a different opinion). There's another test there that is doing something very similar to what this test is doing:
# see https://github.com/linkml/linkml/issues/429
SCHEMA_429 = INPUT_PATH / "personinfo_test_issue_429.yaml"
DATA_429 = INPUT_PATH / "example_personinfo_test_issue_429_data.yaml"
OUT_429 = OUTPUT_PATH / "example_personinfo_test_issue_429_data.ttl"
...
@pytest.fixture
def issue_429_graph():
"""Create RDF graph for issue 429 testing."""
view = SchemaView(str(SCHEMA_429))
container = yaml_loader.load(str(DATA_429), target_class=Container_429)
rdflib_dumper.dump(container, schemaview=view, to_file=str(OUT_429))
g = Graph()
g.parse(str(OUT_429), format="ttl")
return g
|
@ticapix I have moved the work on this PR into the repo branch https://github.com/linkml/linkml-runtime/tree/add_rdf_lang_type_support . If you would like to continue this work please re-open the PR on the mono-repo after the merge from that branch. We'll lift it over for you so it should take less effort. |
Proposal to address linkml/linkml#2475
Without this, it's impossible to convert a Python Instance of a LinkML gen-python class to RDF without loosing language and datatype information.