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

dcterms no longer included among default namespaces in 6.2.0 #2103

Closed
rybesh opened this issue Aug 28, 2022 · 11 comments · Fixed by #2313
Closed

dcterms no longer included among default namespaces in 6.2.0 #2103

rybesh opened this issue Aug 28, 2022 · 11 comments · Fixed by #2313
Assignees
Labels
regression Something stopped working

Comments

@rybesh
Copy link

rybesh commented Aug 28, 2022

rdflib 6.1.1:

>>> import rdflib
>>> g = rdflib.Graph()
>>> g.query("SELECT ?x ?y WHERE { ?x dcterms:type ?y }")
<rdflib.plugins.sparql.processor.SPARQLResult object at 0x1066ba070>

rdflib 6.2.0:

>>> import rdflib
>>> g = rdflib.Graph()
>>> g.query("SELECT ?x ?y WHERE { ?x dcterms:type ?y }")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/ryanshaw/Code/ncg-www/tools/maps/venv/lib/python3.9/site-packages/rdflib/graph.py", line 1389, in query
    return result(processor.query(query_object, initBindings, initNs, **kwargs))
  File "/Users/ryanshaw/Code/ncg-www/tools/maps/venv/lib/python3.9/site-packages/rdflib/plugins/sparql/processor.py", line 78, in query
    query = translateQuery(parsetree, base, initNs)
  File "/Users/ryanshaw/Code/ncg-www/tools/maps/venv/lib/python3.9/site-packages/rdflib/plugins/sparql/algebra.py", line 870, in translateQuery
    q[1] = traverse(
  File "/Users/ryanshaw/Code/ncg-www/tools/maps/venv/lib/python3.9/site-packages/rdflib/plugins/sparql/algebra.py", line 455, in traverse
    r = _traverse(tree, visitPre, visitPost)
  File "/Users/ryanshaw/Code/ncg-www/tools/maps/venv/lib/python3.9/site-packages/rdflib/plugins/sparql/algebra.py", line 412, in _traverse
    e[k] = _traverse(val, visitPre, visitPost)
  File "/Users/ryanshaw/Code/ncg-www/tools/maps/venv/lib/python3.9/site-packages/rdflib/plugins/sparql/algebra.py", line 412, in _traverse
    e[k] = _traverse(val, visitPre, visitPost)
  File "/Users/ryanshaw/Code/ncg-www/tools/maps/venv/lib/python3.9/site-packages/rdflib/plugins/sparql/algebra.py", line 405, in _traverse
    return [_traverse(x, visitPre, visitPost) for x in e]
  File "/Users/ryanshaw/Code/ncg-www/tools/maps/venv/lib/python3.9/site-packages/rdflib/plugins/sparql/algebra.py", line 405, in <listcomp>
    return [_traverse(x, visitPre, visitPost) for x in e]
  File "/Users/ryanshaw/Code/ncg-www/tools/maps/venv/lib/python3.9/site-packages/rdflib/plugins/sparql/algebra.py", line 412, in _traverse
    e[k] = _traverse(val, visitPre, visitPost)
  File "/Users/ryanshaw/Code/ncg-www/tools/maps/venv/lib/python3.9/site-packages/rdflib/plugins/sparql/algebra.py", line 405, in _traverse
    return [_traverse(x, visitPre, visitPost) for x in e]
  File "/Users/ryanshaw/Code/ncg-www/tools/maps/venv/lib/python3.9/site-packages/rdflib/plugins/sparql/algebra.py", line 405, in <listcomp>
    return [_traverse(x, visitPre, visitPost) for x in e]
  File "/Users/ryanshaw/Code/ncg-www/tools/maps/venv/lib/python3.9/site-packages/rdflib/plugins/sparql/algebra.py", line 405, in _traverse
    return [_traverse(x, visitPre, visitPost) for x in e]
  File "/Users/ryanshaw/Code/ncg-www/tools/maps/venv/lib/python3.9/site-packages/rdflib/plugins/sparql/algebra.py", line 405, in <listcomp>
    return [_traverse(x, visitPre, visitPost) for x in e]
  File "/Users/ryanshaw/Code/ncg-www/tools/maps/venv/lib/python3.9/site-packages/rdflib/plugins/sparql/algebra.py", line 412, in _traverse
    e[k] = _traverse(val, visitPre, visitPost)
  File "/Users/ryanshaw/Code/ncg-www/tools/maps/venv/lib/python3.9/site-packages/rdflib/plugins/sparql/algebra.py", line 405, in _traverse
    return [_traverse(x, visitPre, visitPost) for x in e]
  File "/Users/ryanshaw/Code/ncg-www/tools/maps/venv/lib/python3.9/site-packages/rdflib/plugins/sparql/algebra.py", line 405, in <listcomp>
    return [_traverse(x, visitPre, visitPost) for x in e]
  File "/Users/ryanshaw/Code/ncg-www/tools/maps/venv/lib/python3.9/site-packages/rdflib/plugins/sparql/algebra.py", line 412, in _traverse
    e[k] = _traverse(val, visitPre, visitPost)
  File "/Users/ryanshaw/Code/ncg-www/tools/maps/venv/lib/python3.9/site-packages/rdflib/plugins/sparql/algebra.py", line 405, in _traverse
    return [_traverse(x, visitPre, visitPost) for x in e]
  File "/Users/ryanshaw/Code/ncg-www/tools/maps/venv/lib/python3.9/site-packages/rdflib/plugins/sparql/algebra.py", line 405, in <listcomp>
    return [_traverse(x, visitPre, visitPost) for x in e]
  File "/Users/ryanshaw/Code/ncg-www/tools/maps/venv/lib/python3.9/site-packages/rdflib/plugins/sparql/algebra.py", line 412, in _traverse
    e[k] = _traverse(val, visitPre, visitPost)
  File "/Users/ryanshaw/Code/ncg-www/tools/maps/venv/lib/python3.9/site-packages/rdflib/plugins/sparql/algebra.py", line 415, in _traverse
    _e = visitPost(e)  # type: ignore[unreachable]
  File "/Users/ryanshaw/Code/ncg-www/tools/maps/venv/lib/python3.9/site-packages/rdflib/plugins/sparql/algebra.py", line 189, in translatePName
    return prologue.absolutize(p)
  File "/Users/ryanshaw/Code/ncg-www/tools/maps/venv/lib/python3.9/site-packages/rdflib/plugins/sparql/sparql.py", line 412, in absolutize
    return self.resolvePName(iri.prefix, iri.localname)
  File "/Users/ryanshaw/Code/ncg-www/tools/maps/venv/lib/python3.9/site-packages/rdflib/plugins/sparql/sparql.py", line 394, in resolvePName
    raise Exception("Unknown namespace prefix : %s" % prefix)
Exception: Unknown namespace prefix : dcterms
@aucampia
Copy link
Member

This should be fixed in 6.2.0 (#2291), but will be even more fixed in 6.3.2 (#2173). Feel free to re-open this if there are still problems.

@rybesh
Copy link
Author

rybesh commented Mar 20, 2023

I am still getting Unknown namespace prefix : dcterms with rdflib-6.3.1.

@aucampia
Copy link
Member

aucampia commented Mar 20, 2023 via email

@rybesh
Copy link
Author

rybesh commented Mar 20, 2023

The example I provided above for 6.2.0 still fails with 6.3.1.
#2103 (comment)

@aucampia aucampia reopened this Mar 20, 2023
@aucampia
Copy link
Member

@rybesh I see now, the problem is, the default set of bindings after #1686 is "core", but this excludes most of the bindings that were present in 6.1.1.

I think we probably should switch the default from "core" to "rdflib", @nicholascar it would be good to have your input here.

@aucampia
Copy link
Member

@cmungall would be good to get your input on this also.

@aucampia
Copy link
Member

I started this discussion: https://groups.google.com/g/rdflib-dev/c/2Dg7MkldV1c

Unless there is some community consensus I'm going to close this as wontfix, I'm really sorry we missed it, but the damage is done and I fear changing back to what it was will just upset everyone from scratch.

I will also keep working to improve our process and quality assurance to eliminate problems like this in future.

@aucampia aucampia added the wontfix This will not be worked on label Mar 20, 2023
@rybesh
Copy link
Author

rybesh commented Mar 20, 2023

dcterms is one of the most used namespaces. If rdflib is going to include any namespaces by default, dcterms should surely be one of them…

@aucampia
Copy link
Member

I will see where the discussion goes, if I can get feedback from @nicholascar and @cmungall and/or consensus on that mailing list discussion I will fix the regressions.

@nicholascar
Copy link
Member

I think we probably should switch the default from "core" to "rdflib"

I preferred to have more common namespaces bound by default, so "rdflib" instead of "core", but there was push-back on pre-binding many from some (I think more than one!) commenters on the update. However, I still think that binding more is ok, as long as 1. what is bound is known and 2. things can be overridden. Both of these things are true: the NamespaceManager records all prefixes registered for a graph and things can be overridden with g.bind().

So I still support binding according to "rdflib" by default, not "core".

@aucampia aucampia self-assigned this Mar 24, 2023
@aucampia
Copy link
Member

Given the feedback [ref] I will do the following for 6.3.2

  • Change the prefix for https://schema.org/ from sdo to schema
  • Change the default bindings from core to rdflib, which is the same behaviour as in 6.1.1
  • Add a docstring with recommendations from Wes.

@aucampia aucampia removed the wontfix This will not be worked on label Mar 24, 2023
aucampia added a commit to aucampia/rdflib that referenced this issue Mar 25, 2023
The namespaces bound by default by `rdflib.graph.Graph` and
`rdflib.namespace.NamespaceManager` was reduced in version 6.2.0 of RDFLib,
however, this also would cause code that worked with 6.1.1 to break, so this
constituted a breaking change. This change restores the previous behavior,
binding the same namespaces as was bound in 6.1.1.

To bind a reduced set of namespaces the `bind_namespaces` parameter of
`rdflib.graph.Graph` or `rdflib.namespace.NamespaceManager` can be used.

- Closes <RDFLib#2103>.
aucampia added a commit to aucampia/rdflib that referenced this issue Mar 25, 2023
The namespaces bound by default by `rdflib.graph.Graph` and
`rdflib.namespace.NamespaceManager` was reduced in version 6.2.0 of RDFLib,
however, this also would cause code that worked with 6.1.1 to break, so this
constituted a breaking change. This change restores the previous behavior,
binding the same namespaces as was bound in 6.1.1.

To bind a reduced set of namespaces the `bind_namespaces` parameter of
`rdflib.graph.Graph` or `rdflib.namespace.NamespaceManager` can be used.

- Closes <RDFLib#2103>.
aucampia added a commit to aucampia/rdflib that referenced this issue Mar 26, 2023
The namespaces bound by default by `rdflib.graph.Graph` and
`rdflib.namespace.NamespaceManager` was reduced in version 6.2.0 of RDFLib,
however, this also would cause code that worked with 6.1.1 to break, so this
constituted a breaking change. This change restores the previous behavior,
binding the same namespaces as was bound in 6.1.1.

To bind a reduced set of namespaces the `bind_namespaces` parameter of
`rdflib.graph.Graph` or `rdflib.namespace.NamespaceManager` can be used.

- Closes <RDFLib#2103>.
aucampia added a commit that referenced this issue Mar 26, 2023
The namespaces bound by default by `rdflib.graph.Graph` and
`rdflib.namespace.NamespaceManager` was reduced in version 6.2.0 of RDFLib,
however, this also would cause code that worked with 6.1.1 to break, so this
constituted a breaking change. This change restores the previous behaviour,
binding the same namespaces as was bound in 6.1.1.

To bind a reduced set of namespaces, the `bind_namespaces` parameter of
`rdflib.graph.Graph` or `rdflib.namespace.NamespaceManager` can be used.

- Closes <#2103>.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression Something stopped working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants