-
Notifications
You must be signed in to change notification settings - Fork 31
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
WIP: jsonld ver. 1.1 exports #140
Conversation
@cmaumet This is the branch I'm working with for the JSON-LD 1.1 exports. Essentially there are 2 parts to it, a call to Core.createDefaultJSONLDcontext() which currently only adds the namespaces from Constants.py and NIDM experiment terms (it doesn't yet get all the terms from the NIDM-E OWL files like it should) and then it adds any additional prefixes that are in the current NIDM-E graph in the event someone loaded a NIDM-E graph which includes terms not in the Contants.py namespaces and/or (eventually) the NIDM-E OWL files (see: https://github.com/incf-nidash/PyNIDM/blob/master/nidm/experiment/Core.py#L433). The test NIDM TTL files I'm using are here (for example): https://github.com/dbkeator/simple2_NIDM_examples/blob/master/datasets.datalad.org/abide/RawDataBIDS/CMU_a/nidm.ttl
The utility I use to test converting the NIDM TTL files -> JSON-LD is here: https://github.com/incf-nidash/PyNIDM/blob/master/nidm/experiment/tools/nidm_utils.py
The error I'm getting when running a conversion is shown below. This started when I moved to using pyld instead of rdflib-jsonld:
|
@dbkeator - which version of pyld do you have? |
Thank you @dbkeator! I'm pingging @natachaperez who will work on this with me. |
@satra ver 1.0.5 |
can you serialize your graph to turtle and the context to json and share it with me? |
@satra Below a TTL file serialization and the corresponding JSON-LD serialization done with rdflib-jsonld: These files were created with the code in Core.serializeJSONLD() function except that instead of returning the rdflib-jsonld serialization I did the pyld trick you mentioned at OHBM (or at least I thought I did)...see the old serialization code commented out below with the return statement replaced with the following 3 lines of code (or in full fancy color: PR140)...which generates the pyld error with context...
|
nidm/experiment/Core.py
Outdated
#WIP: LOOK AT https://github.com/satra/nidm-jsonld | ||
return rdf_graph_parse.serialize(format='json-ld', context=context, indent=4).decode('ASCII') | ||
#return rdf_graph_parse.serialize(format='json-ld', context=context, indent=4).decode('ASCII') | ||
g=rdf_graph_parse.serialize(format='json-ld', context=context, indent=4).decode('ASCII') |
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.
g=rdf_graph_parse.serialize(format='json-ld', context=context, indent=4).decode('ASCII') | |
g=rdf_graph_parse.serialize(format='json-ld', indent=4).decode('ASCII') |
nidm/experiment/Core.py
Outdated
#return rdf_graph_parse.serialize(format='json-ld', context=context, indent=4).decode('ASCII') | ||
g=rdf_graph_parse.serialize(format='json-ld', context=context, indent=4).decode('ASCII') | ||
import pyld as ld | ||
return ld.jsonld.compact(json.loads(g), context) |
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.
and make sure that:
context['@version'] = 1.1
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.
So this worked. My main problem appeared to be that I was setting context['@Version'] to the string 1.1 not the floating point number. Anyway it serializes now...but my tests still fail because pyld needs to be added as a required package.
left some comments. |
@@ -58,5 +58,5 @@ | |||
#REQUIRES = ["prov", "rdflib", "graphviz", "pydotplus", "pydot", "validators", "requests", "fuzzywuzzy", "pygithub", | |||
# "pandas", "pybids", "duecredit", "pytest", "graphviz", "click", "ontquery"] | |||
INSTALL_REQUIRES = ["prov", "rdflib", "graphviz", "pydotplus", "pydot", "validators", "requests", "fuzzywuzzy", "pygithub", | |||
"pandas", "pybids", "duecredit", "pytest", "graphviz", "click", "ontquery","rdflib-jsonld"] | |||
"pandas", "pybids", "duecredit", "pytest", "graphviz", "click", "ontquery","rdflib-jsonld","pyld"] |
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.
"pandas", "pybids", "duecredit", "pytest", "graphviz", "click", "ontquery","rdflib-jsonld","pyld"] | |
"pandas", "pybids", "duecredit", "pytest", "graphviz", "click", "ontquery","rdflib-jsonld","pyld", "neurdflib"] |
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.
just ensuring that the @tgbugs version of rdflib is installed
No description provided.