RDFLib / rdflib-jsonld

JSON-LD parser and serializer plugins for RDFLib
Other
280 stars 71 forks source link

Feature/json ld 1.1 #74

Closed niklasl closed 3 years ago

niklasl commented 4 years ago

This is a set of features which add, as it stands, some support for parsing JSON-LD 1.1. This PR is created to solicit feedback on when this set is considered complete enough for merging into master and cutting a release from.

It could be left hanging indefinitely (if full feature parity is considered preferable) or merged ASAP, depending on the practicality of this state in light of required use cases by users of this library (e.g. #54 ).

(Merging does not preclude more features being added afterwards of course.)

Currently, this can be tested against an external clone of the official JSON-LD 1.1. The test suite runner is set up to select that (over the old, local copy in this repo) if an environment variable is set, along the lines of:

    $ cd /tmp/ # or some other location
    $ git clone https://github.com/w3c/json-ld-api.git
    $ export JSONLD_TESTSUITE=$(pwd)/json-ld-api/tests
    $ cd -
    $ python setup.py test
nicholascar commented 4 years ago

New RDF types from JSON-LD 1.1. were snuck into the rdflib 5.0.0 prerelease recently (see https://github.com/RDFLib/rdflib/pull/970) so it would be great to see this rdflib-jsonld JSON-LD 1.1. update come through as a release to match soon.

nicholascar commented 4 years ago

@niklasl please could you contact me via email (see my profile) as we have a release issue now due to some personal circumstances

sroertgen commented 3 years ago

Does this feature set support array-type for @container (e.g. https://w3c.github.io/json-ld-syntax/#representing-singular-values-as-arrays)? I always get the following error, when trying to use it:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-245-a35933279054> in <module>
    151 output_turtle = g.serialize(format='turtle', base=n).decode("utf-8")
    152 output_xml = g.serialize(format='xml', base=n).decode("utf-8")
--> 153 output_jsonld = g.serialize(format='json-ld', context=context).decode("utf-8")
    154 
    155 

~/.virtualenvs/rdf/lib/python3.7/site-packages/rdflib/graph.py in serialize(self, destination, format, base, encoding, **args)
    962         if destination is None:
    963             stream = BytesIO()
--> 964             serializer.serialize(stream, base=base, encoding=encoding, **args)
    965             return stream.getvalue()
    966         if hasattr(destination, "write"):

~/.virtualenvs/rdf/lib/python3.7/site-packages/rdflib_jsonld/serializer.py in serialize(self, stream, base, encoding, **kwargs)

~/.virtualenvs/rdf/lib/python3.7/site-packages/rdflib_jsonld/serializer.py in from_rdf(graph, context_data, base, use_native_types, use_rdf_type, auto_compact, startnode, index)

~/.virtualenvs/rdf/lib/python3.7/site-packages/rdflib_jsonld/context.py in __init__(self, source, base)

~/.virtualenvs/rdf/lib/python3.7/site-packages/rdflib_jsonld/context.py in load(self, source, base)

~/.virtualenvs/rdf/lib/python3.7/site-packages/rdflib_jsonld/context.py in _read_source(self, source, source_url)

~/.virtualenvs/rdf/lib/python3.7/site-packages/rdflib_jsonld/context.py in _read_term(self, source, name, dfn)

~/.virtualenvs/rdf/lib/python3.7/site-packages/rdflib_jsonld/context.py in add_term(self, name, idref, coercion, container, language, reverse)

TypeError: unhashable type: 'list'
jonassmedegaard commented 3 years ago

Personally I see no reason to let this hang indefinitely, but would appreciate it getting merged and relased as minor release when working - and then maybe when complete released as a major version (but not let that stall usable albeit incomplete parts).

nicholascar commented 3 years ago

@jonassmedegaard the issue is really only the lack of mantainers' availability, not any issues with the PR. I do think merging is the right thing and then fixing if need be, but we are currently stalled.

I propose to merge within a week (by Christmas) unless someone objects. I'm flagging @ashleysommer @white-gecko as co-RDFlib maintainers and @niklasl just in case he's watching!

jonassmedegaard commented 3 years ago

Yeah, that was my polite way of saying the same :+1: My interest concretely is in getting this nice improvement into next Debian stable release happening at the beginning of the new year and needs things settled here upstream before then.

nicholascar commented 3 years ago

OK, well we are on notice now so we'll have this merged within a week or so.

After a complete JSON 1.1 release here, we will likely merge this repo into the rdflib core repository, so there will be less maintenance work all round.

nicholascar commented 3 years ago

I'm closing this PR as we are reviewing the JSON-LD 1.1 capability in the feature branch from the ground up - using the W3C tests. Will re-issue a PR when that work is complete.

white-gecko commented 3 years ago

As this PR is closed, can we delete the branch?

nicholascar commented 2 years ago

Yes, done