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 parser doesn't restore root directory #2164

Closed
hsolbrig opened this issue Nov 21, 2022 · 1 comment
Closed

JSON-LD parser doesn't restore root directory #2164

hsolbrig opened this issue Nov 21, 2022 · 1 comment
Labels
bug Something isn't working format: JSON-LD Related to JSON-LD format. marked for closing The issue or PR will be closed soon if no further feedback is provided.

Comments

@hsolbrig
Copy link
Contributor

It appears that the working directory isn't refreshed when reading when reading relative context files.

In the directory structure:

test.jsonld
contexts/person.jsonld
contexts/place.jsonld

Where test.jsonld contains:

{
  "@context": [
    "contexts/person.jsonld",
    "contexts/place.jsonld"
  ]
}

rdfpipe -i json-ld -o turtle ldbug.jsonld returns the following:

Traceback (most recent call last):
  File "/Users/solbrig/Development/json_ld_tests/venv/bin/rdfpipe", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/solbrig/Development/json_ld_tests/venv/lib/python3.11/site-packages/rdflib/tools/rdfpipe.py", line 198, in main
    parse_and_serialize(
  File "/Users/solbrig/Development/json_ld_tests/venv/lib/python3.11/site-packages/rdflib/tools/rdfpipe.py", line 52, in parse_and_serialize
    graph.parse(fpath, format=use_format, **kws)
  File "/Users/solbrig/Development/json_ld_tests/venv/lib/python3.11/site-packages/rdflib/graph.py", line 1977, in parse
    context.parse(source, publicID=publicID, format=format, **args)
  File "/Users/solbrig/Development/json_ld_tests/venv/lib/python3.11/site-packages/rdflib/graph.py", line 1330, in parse
    parser.parse(source, self, **args)
  File "/Users/solbrig/Development/json_ld_tests/venv/lib/python3.11/site-packages/rdflib/plugins/parsers/jsonld.py", line 115, in parse
    to_rdf(data, conj_sink, base, context_data, version, generalized_rdf)
  File "/Users/solbrig/Development/json_ld_tests/venv/lib/python3.11/site-packages/rdflib/plugins/parsers/jsonld.py", line 134, in to_rdf
    return parser.parse(data, context, dataset)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/solbrig/Development/json_ld_tests/venv/lib/python3.11/site-packages/rdflib/plugins/parsers/jsonld.py", line 154, in parse
    context.load(local_context, context.base)
  File "/Users/solbrig/Development/json_ld_tests/venv/lib/python3.11/site-packages/rdflib/plugins/shared/jsonld/context.py", line 375, in load
    self._prep_sources(base, source, sources, referenced_contexts)
  File "/Users/solbrig/Development/json_ld_tests/venv/lib/python3.11/site-packages/rdflib/plugins/shared/jsonld/context.py", line 404, in _prep_sources
    new_ctx = self._fetch_context(
              ^^^^^^^^^^^^^^^^^^^^
  File "/Users/solbrig/Development/json_ld_tests/venv/lib/python3.11/site-packages/rdflib/plugins/shared/jsonld/context.py", line 440, in _fetch_context
    source = source_to_json(source_url)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/solbrig/Development/json_ld_tests/venv/lib/python3.11/site-packages/rdflib/plugins/shared/jsonld/util.py", line 35, in source_to_json
    source = create_input_source(source, format="json-ld")
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/solbrig/Development/json_ld_tests/venv/lib/python3.11/site-packages/rdflib/parser.py", line 404, in create_input_source
    ) = _create_input_source_from_location(
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/solbrig/Development/json_ld_tests/venv/lib/python3.11/site-packages/rdflib/parser.py", line 456, in _create_input_source_from_location
    file = open(filename, "rb")
           ^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/Users/solbrig/Development/json_ld_tests/contexts/contexts/place.jsonld'
@hsolbrig hsolbrig added the bug Something isn't working label Nov 21, 2022
hsolbrig added a commit to hsolbrig/rdflib that referenced this issue Nov 22, 2022
@hsolbrig hsolbrig mentioned this issue Nov 22, 2022
@hsolbrig hsolbrig added the format: JSON-LD Related to JSON-LD format. label Nov 22, 2022
@aucampia
Copy link
Member

Closing this as the PR that fixed it was merged.

@aucampia aucampia added the marked for closing The issue or PR will be closed soon if no further feedback is provided. label Mar 24, 2023
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. marked for closing The issue or PR will be closed soon if no further feedback is provided.
Projects
None yet
Development

No branches or pull requests

2 participants