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

Remove (soft)dependency on rdflib_jsonld #93

Closed
Panaetius opened this issue Sep 8, 2021 · 10 comments · Fixed by #94
Closed

Remove (soft)dependency on rdflib_jsonld #93

Panaetius opened this issue Sep 8, 2021 · 10 comments · Fixed by #94

Comments

@Panaetius
Copy link
Contributor

#92 fixed RDFLib 6.0, but a big change in RDFlib 6.0 was integrating rdflib_jsonld into RDFlib itself: RDFLib/rdflib#1354

Due to this, the rdflib_jsonld project has been archived and is not maintained anymore: https://github.com/RDFLib/rdflib-jsonld#archived

Since rdflib_jsonld cannot be installed anymore with the newest version of setuptools, since it has use_2to3 set to true, see pypa/setuptools#2769, this makes pySHACL unusable with JSON-LD with the newest version of setuptools.

Graph().serialize(format='json-ld') should just work out of the box now with RDFLib 6.0.

One slightly related issue (but irrelevant if the move away from rdflib_jsonld is done) is that the code in https://github.com/RDFLib/pySHACL/blob/master/pyshacl/rdfutil/load.py#L21-L26 doesn't work:

File "/home/zenon/DEV/ETH/renku-python/renku/core/utils/shacl.py", line 21, in <module>
    from pyshacl import validate
  File "/home/zenon/.pyenv/versions/renku-python/lib/python3.7/site-packages/pyshacl/__init__.py", line 4, in <module>
    from .shapes_graph import ShapesGraph
  File "/home/zenon/.pyenv/versions/renku-python/lib/python3.7/site-packages/pyshacl/shapes_graph.py", line 7, in <module>
    from .constraints.constraint_component import CustomConstraintComponentFactory
  File "/home/zenon/.pyenv/versions/renku-python/lib/python3.7/site-packages/pyshacl/constraints/__init__.py", line 4, in <module>
    from pyshacl.constraints.constraint_component import ConstraintComponent
  File "/home/zenon/.pyenv/versions/renku-python/lib/python3.7/site-packages/pyshacl/constraints/constraint_component.py", line 36, in <module>
    from pyshacl.rdfutil import stringify_node
  File "/home/zenon/.pyenv/versions/renku-python/lib/python3.7/site-packages/pyshacl/rdfutil/__init__.py", line 7, in <module>
    from .load import get_rdf_from_web, load_from_source  # noqa: F401
  File "/home/zenon/.pyenv/versions/renku-python/lib/python3.7/site-packages/pyshacl/rdfutil/load.py", line 22, in <module>
    import rdflib_jsonld  # noqa: F401
ModuleNotFoundError: No module named 'rdflib_jsonld'

It raises a ModuleNotFoundError for me, not an IndexError on Python 3.7.4

@ashleysommer
Copy link
Collaborator

Hi @Panaetius
Thanks for raising the issue.

I was the developer who integrated json-ld into RDFLib recently, so I know of the changes in RDFlib v6.0.0.

I didn't however know that the json-ld repo had been archived. I thought the original developer was releasing upstream updates via that repository.

As you correctly pointed out in your PR, if we don't attempt to import json-ld from the module, and instead rely on RDFLib support, then we will have a dependency on RDFLib >= 6.0.0.
That may not necessarily be a bad thing, and means I could remove some other code in RDFLib that works around bugs in RDFLib 4.2.1 and v5.0 (and removing the need for the monkey module entirely).

One slightly related issue (but irrelevant if the move away from rdflib_jsonld is done) is that the code in https://github.com/RDFLib/pySHACL/blob/master/pyshacl/rdfutil/load.py#L21-L26 doesn't work:

Thanks! That is a typo, and I don't know how it hasn't been spotted until now. That should be ImportError not IndexError.

@ashleysommer
Copy link
Collaborator

I'm going to put out one last release of PySHACL (v0.16.2) that works with RDFLib 5.0, and has that ImportError bug fixed.
After that, I'll pull in your PRs (or do similar changes myself) and put out PySHACL v0.17.0 that works only with RDFLib >=6.0.

@ashleysommer
Copy link
Collaborator

@Panaetius
PySHACL v0.16.2 is released, with the ImportError bug fixed, and the required version of Black bumped to 21.8b0 to fix the black bug.

@Panaetius
Copy link
Contributor Author

Thank you!

Though as it'll still have an issue with setuptools and rdflib-jsonld<0.6.0 I'll have to wait for a release that works with rdflib 6.0.0 to do a hotfix on our end (or a release with rdflib-jsonld 0.6.0 but I'd prefer to do a proper hotfix with the new rdflib)

@ashleysommer
Copy link
Collaborator

ashleysommer commented Sep 13, 2021

Though as it'll still have an issue with setuptools and rdflib-jsonld<0.6.0

I know. I realised that after the release. I have a fix, by making rdflib-jsonld optional in pyproject, but it needs to wait until OWL-RL 5.2.2 is released which removes it's hard dependency on rdflib_jsonld.

@ashleysommer
Copy link
Collaborator

@Panaetius
Ok, OWL-RL update is published, and PySHACL v0.16.2.post1 is pushed up to pypi which finally means now rdflib_jsonld dependency is optional.
Let me know if that resolves the problem you were seeing 😄

@ashleysommer
Copy link
Collaborator

And finally, to round it all out, PySHACL v0.17 is now released with Minimum RDFLib 6.0.0, minimum OWL-RL 5.2.3, and Minimum python v3.7. Happy days!

@Panaetius
Copy link
Contributor Author

@ashleysommer Thanks a lot! I almost got a hotfix release ready for our software with these changes but it'll have to wait until tomorrow. But everything works in my tests 🎉

@ashleysommer
Copy link
Collaborator

@Panaetius. As pointed out in #95, this fix was not quite enough to make that dependency optional.

Versions v0.16.2.post2 and v0.17.0.post2 are now published, which resolves that error. Sorry for the mixup.

@Panaetius
Copy link
Contributor Author

no worries, thank you very much for looking into it. We have a hotfix release with 0.17.post2 and it works great 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants