invalid remote context when testing on local sever
wdduncan opened this issue · 0 comments
I am trying to test different contexts applied to json file. I have created a very simple context file (named mycontext.json
) on my local machine (a 2019 MacPro) with the contents:
{ "name": "http://example.com#name", "age": "http://example.com#age"}
Next I start a local web server on my machine using jekyll serve
. I can test that my file is accessible in the web browser by navigating to http://127.0.0.1:4000/mycontext.json
or using the python requests
library: requests.get("http://127.0.0.1:4000/mycontext.json").text
.
Each test works fine in that it returns the context of mycontext.json
.
The json file (named test-data.json
) references the json-ld context. Its contents are:
{
"@context": "http://127.0.0.1:4000/mycontext.json",
"name:": "Bill",
"age": "48"
}
However, when I parse this in rdflb
, I get an INVALID_REMOTE_CONTEXT
error.
That is, g.parse("test-data.json", format="json-ld")
produces error:
:
:
~/opt/anaconda3/lib/python3.7/site-packages/rdflib_jsonld/context.py in _prep_sources(self, base, inputs, sources, referenced_contexts, in_source_url)
205 source = source_to_json(source_url)
206 if CONTEXT not in source:
--> 207 raise errors.INVALID_REMOTE_CONTEXT
208 else:
209 source_url = in_source_url
JSONLDException: invalid remote context
There are a lot of error messages about this, but this one seems most relevant.
I've tried initializing the graph using both Graph()
and ConjunctiveGraph()
. Same result for each.
I've also tried:
- placing the context file in its own directory, and calling with:
"@context": "http://127.0.0.1:4000/context/
- giving the context a non-json extension, and calling with:
"@context": "http://127.0.0.1:4000/context/c1"
I'm really quite stumped at this point :(
I realized that I can programmatically parse/combine the context and data files into a single file. But, our goal is to create context files locally and test them on json files. If we are satisfied, we can then deploy the context files onto public web serve w/o also deploying the data.