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

[json-ld serialisation] Context.to_dict() is not implemented (anymore?) #2138

Closed
proycon opened this issue Oct 15, 2022 · 1 comment · Fixed by #2310
Closed

[json-ld serialisation] Context.to_dict() is not implemented (anymore?) #2138

proycon opened this issue Oct 15, 2022 · 1 comment · Fixed by #2310
Assignees
Labels
bug Something isn't working format: JSON-LD Related to JSON-LD format. regression Something stopped working serialization Related to serialization.

Comments

@proycon
Copy link

proycon commented Oct 15, 2022

The to_dict() method is missing on Context:

Though this seems to have been implemented and merged before: RDFLib/rdflib-jsonld#51 , it is no longer present in the current codebase. However, it is still referenced: https://github.com/RDFLib/rdflib/blob/main/rdflib/plugins/serializers/jsonld.py#L126 , so this leads to an error if you pass an explicit Context instance:

>>> g.serialize(format='json-ld', auto_compact=True,context=c3)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/proycon/work/codemetapy/env/lib/python3.10/site-packages/rdflib/graph.py", line 1186, in serialize
    serializer.serialize(stream, base=base, encoding="utf-8", **args)
  File "/home/proycon/work/codemetapy/env/lib/python3.10/site-packages/rdflib/plugins/serializers/jsonld.py", line 84, in serialize
    obj = from_rdf(
  File "/home/proycon/work/codemetapy/env/lib/python3.10/site-packages/rdflib/plugins/serializers/jsonld.py", line 126, in from_rdf
    context_data = context.to_dict()
AttributeError: 'Context' object has no attribute 'to_dict'

Perhaps the solution is to re-apply the old pull request?

@aucampia aucampia added bug Something isn't working regression Something stopped working serialization Related to serialization. format: JSON-LD Related to JSON-LD format. labels Mar 19, 2023
@aucampia aucampia self-assigned this Mar 19, 2023
@aucampia
Copy link
Member

Thanks for reporting this, I will have a look when I can.

aucampia added a commit that referenced this issue Mar 25, 2023
`Context.to_dict` is used in JSON-LD serialization, but it was not implemented.
This change adds the method.

- Closes <#2138>.

---------

Co-authored-by: Marc-Antoine Parent <maparent@acm.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working format: JSON-LD Related to JSON-LD format. regression Something stopped working serialization Related to serialization.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants