-
Notifications
You must be signed in to change notification settings - Fork 547
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
Strange bug of notation3 serialization that occur with “probability” #1701
Comments
Seems to be the same issue as #1807 |
This seems to happen every time the first element in rdflib/rdflib/plugins/serializers/turtle.py Line 239 in e9f5c22
I'm guessing this may be because because the serializer thinks it already serialized the triple as it has been serialized inside the quoted graph. Checking further. |
Indeed it is, debugging inside master...aucampia:iwana-20220419T2343-n3_serialize_quoted_graph 20220419T234518 iwana@iwana-pc00.coop.no:~/sw/d/github.com/iafork/rdflib.cleanish
$ .venv/bin/python3 -m pytest 'test/test_issues/test_issue1701.py::test_issue1701_a' -rA --log-cli-level DEBUG
============================================================================ test session starts ============================================================================
platform linux -- Python 3.7.13, pytest-7.1.1, pluggy-1.0.0
rootdir: /home/iwana/sw/d/github.com/iafork/rdflib.cleanish, configfile: pyproject.toml
plugins: subtests-0.7.0, md-report-0.2.0, cov-3.0.0
collected 1 item
test/test_issues/test_issue1701.py::test_issue1701_a
------------------------------------------------------------------------------- live log call -------------------------------------------------------------------------------
2022-04-19T23:45:23 DEBUG root turtle.py:228:serialize entry ...
2022-04-19T23:45:23 DEBUG root turtle.py:242:serialize subjects_list = [<Graph identifier=_:Formula3 (<class 'rdflib.graph.QuotedGraph'>)>, rdflib.term.URIRef('http://example.com/a'), rdflib.term.URIRef('http://example.com/d')]
2022-04-19T23:45:23 DEBUG root turtle.py:249:serialize subject (isDone=False) = {this rdflib.identifier _:_:Formula3;rdflib:storage [a rdflib:Store;rdfs:label 'Memory']}
2022-04-19T23:45:23 DEBUG root turtle.py:228:serialize entry ...
2022-04-19T23:45:23 DEBUG root turtle.py:242:serialize subjects_list = [rdflib.term.URIRef('http://example.com/a')]
2022-04-19T23:45:23 DEBUG root turtle.py:249:serialize subject (isDone=False) = http://example.com/a
2022-04-19T23:45:23 DEBUG root turtle.py:228:serialize entry ...
2022-04-19T23:45:23 DEBUG root turtle.py:242:serialize subjects_list = [rdflib.term.URIRef('http://example.com/d')]
2022-04-19T23:45:23 DEBUG root turtle.py:249:serialize subject (isDone=False) = http://example.com/d
2022-04-19T23:45:23 DEBUG root turtle.py:249:serialize subject (isDone=True) = http://example.com/a
2022-04-19T23:45:23 DEBUG root turtle.py:249:serialize subject (isDone=True) = http://example.com/d
2022-04-19T23:45:23 DEBUG root test_issue1701.py:42:test_issue1701_a data_s = @prefix : <http://example.com/> .
{
:a :b :c .
} => {
:d :e :f .
} .
XFAIL () [100%]
========================================================================== short test summary info ==========================================================================
XFAIL test/test_issues/test_issue1701.py::test_issue1701_a
https://github.com/RDFLib/rdflib/issues/1701
============================================================================ 1 xfailed in 0.11s ============================================================================= |
Still digging around here, but I suspect this is wrong: rdflib/rdflib/plugins/serializers/n3.py Lines 66 to 73 in e9f5c22
I don't think this should be processing the triples in quoted graphs. |
This seems to do the trick, will look further tomorrow: diff --git a/rdflib/plugins/serializers/n3.py b/rdflib/plugins/serializers/n3.py
index f82a08a2..1e91d8f3 100644
--- a/rdflib/plugins/serializers/n3.py
+++ b/rdflib/plugins/serializers/n3.py
@@ -25,13 +25,14 @@ class N3Serializer(TurtleSerializer):
def subjectDone(self, subject):
super(N3Serializer, self).subjectDone(subject)
- if self.parent:
- self.parent.subjectDone(subject)
+ # if self.parent:
+ # self.parent.subjectDone(subject)
def isDone(self, subject):
- return super(N3Serializer, self).isDone(subject) and (
- not self.parent or self.parent.isDone(subject)
- )
+ return super(N3Serializer, self).isDone(subject)
+ # return super(N3Serializer, self).isDone(subject) and (
+ # not self.parent or self.parent.isDone(subject)
+ # )
def startDocument(self):
super(N3Serializer, self).startDocument()
@@ -65,12 +66,12 @@ class N3Serializer(TurtleSerializer):
def preprocessTriple(self, triple):
super(N3Serializer, self).preprocessTriple(triple)
- if isinstance(triple[0], Graph):
- for t in triple[0]:
- self.preprocessTriple(t)
- if isinstance(triple[2], Graph):
- for t in triple[2]:
- self.preprocessTriple(t)
+ # if isinstance(triple[0], Graph):
+ # for t in triple[0]:
+ # self.preprocessTriple(t)
+ # if isinstance(triple[2], Graph):
+ # for t in triple[2]:
+ # self.preprocessTriple(t)
def getQName(self, uri, gen_prefix=True):
qname = None
|
This patch fixes two issues with the N3 serializer: - The N3 serializer incorrectly considered a subject as already serialized if it has been serialized inside a quoted graph. - The N3 serializer does not consider that the predicate of a triple can also be a graph. Other changes included in this patch: - Added the N3 test suite from https://github.com/w3c/N3/tree/master/tests - Added `test/data/fetcher.py` which fetches remote test data. - Changed `test.testutils.GraphHelper` to support nested graphs. Fixes: - RDFLib#1807 - RDFLib#1701 Related: - RDFLib#1840
This patch fixes two issues with the N3 serializer: - The N3 serializer incorrectly considered a subject as already serialized if it has been serialized inside a quoted graph. - The N3 serializer does not consider that the predicate of a triple can also be a graph. Other changes included in this patch: - Added the N3 test suite from https://github.com/w3c/N3/tree/master/tests - Added `test/data/fetcher.py` which fetches remote test data. - Changed `test.testutils.GraphHelper` to support nested graphs. Fixes: - RDFLib#1807 - RDFLib#1701 Related: - RDFLib#1840
This patch adds the N3 test suite from https://github.com/w3c/N3/tree/master/tests and also adds `test/data/fetcher.py` which fetches remote test data. Remotes are added for some data in the test data directory, more will be added later and the data itself will be corrected. I'm mainly doing this because I want N3 test data to test the fix I'm making for these issues: - RDFLib#1807 - RDFLib#1701 Related to: - RDFLib#1840
This patch fixes two issues with the N3 serializer: - The N3 serializer incorrectly considered a subject as already serialized if it has been serialized inside a quoted graph. - The N3 serializer does not consider that the predicate of a triple can also be a graph. Other changes included in this patch: - Changed `test.testutils.GraphHelper` to support nested graphs. Fixes: - RDFLib#1807 - RDFLib#1701
This patch fixes two issues with the N3 serializer: - The N3 serializer incorrectly considered a subject as already serialized if it has been serialized inside a quoted graph. - The N3 serializer does not consider that the predicate of a triple can also be a graph. Other changes included in this patch: - Changed `test.testutils.GraphHelper` to support nested graphs. Fixes: - RDFLib#1807 - RDFLib#1701
This patch fixes two issues with the N3 serializer: - The N3 serializer incorrectly considered a subject as already serialized if it has been serialized inside a quoted graph. - The N3 serializer does not consider that the predicate of a triple can also be a graph. Other changes included in this patch: - Changed `test.testutils.GraphHelper` to support nested/quoted graphs. - Moved the tests from `test/test_n3_formula.py` into `test/test_serializers/test_serializer_n3.py`. - Include positive syntax tests from the N3 test suite that is smaller than 1024KB and that is not using new N3 syntax into round trip tests. This is mainly to check that there is no regressions after the changes made. Fixes: - RDFLib#1807 - RDFLib#1701
This patch fixes two issues with the N3 serializer: - The N3 serializer incorrectly considered a subject as already serialized if it has been serialized inside a quoted graph. - The N3 serializer does not consider that the predicate of a triple can also be a graph. Other changes included in this patch: - Changed `test.testutils.GraphHelper` to support nested/quoted graphs. - Moved the tests from `test/test_n3_formula.py` into `test/test_serializers/test_serializer_n3.py`. - Include positive syntax tests from the N3 test suite that is smaller than 1024KB and that is not using new N3 syntax into round trip tests. This is mainly to check that there is no regressions after the changes made. Fixes: - RDFLib#1807 - RDFLib#1701
This patch fixes two issues with the N3 serializer: - The N3 serializer incorrectly considered a subject as already serialized if it has been serialized inside a quoted graph. - The N3 serializer does not consider that the predicate of a triple can also be a graph. Other changes included in this patch: - Changed `test.testutils.GraphHelper` to support nested/quoted graphs. - Moved the tests from `test/test_n3_formula.py` into `test/test_serializers/test_serializer_n3.py`. - Include positive syntax tests from the N3 test suite that is smaller than 1024KB and that is not using new N3 syntax into round trip tests. This is mainly to check that there is no regressions after the changes made. Fixes: - RDFLib#1807 - RDFLib#1701
This patch fixes two issues with the N3 serializer: - The N3 serializer incorrectly considered a subject as already serialized if it has been serialized inside a quoted graph. - The N3 serializer does not consider that the predicate of a triple can also be a graph. Other changes included in this patch: - Changed `test.testutils.GraphHelper` to support nested/quoted graphs. - Moved the tests from `test/test_n3_formula.py` into `test/test_serializers/test_serializer_n3.py`. - Include positive syntax tests from the N3 test suite that is smaller than 1024KB and that is not using new N3 syntax into round trip tests. This is mainly to check that there is no regressions after the changes made. Fixes: - RDFLib#1807 - RDFLib#1701
This patch fixes two issues with the N3 serializer: - The N3 serializer incorrectly considered a subject as already serialized if it has been serialized inside a quoted graph. - The N3 serializer does not consider that the predicate of a triple can also be a graph. Other changes included in this patch: - Changed `test.testutils.GraphHelper` to support nested/quoted graphs. - Moved the tests from `test/test_n3_formula.py` into `test/test_serializers/test_serializer_n3.py`. - Include positive syntax tests from the N3 test suite that is smaller than 1024KB and that is not using new N3 syntax into round trip tests. This is mainly to check that there is no regressions after the changes made. Fixes: - RDFLib#1807 - RDFLib#1701
This patch fixes two issues with the N3 serializer: - The N3 serializer incorrectly considered a subject as already serialized if it has been serialized inside a quoted graph. - The N3 serializer does not consider that the predicate of a triple can also be a graph. Other changes included in this patch: - Changed `test.testutils.GraphHelper` to support nested/quoted graphs. - Moved the tests from `test/test_n3_formula.py` into `test/test_serializers/test_serializer_n3.py`. - Include positive syntax tests from the N3 test suite that is smaller than 1024KB and that is not using new N3 syntax into round trip tests. This is mainly to check that there is no regressions after the changes made. Fixes: - RDFLib#1807 - RDFLib#1701
This patch fixes two issues with the N3 serializer: - The N3 serializer incorrectly considered a subject as already serialized if it has been serialized inside a quoted graph. - The N3 serializer does not consider that the predicate of a triple can also be a graph. Other changes included in this patch: - Changed `test.testutils.GraphHelper` to support nested/quoted graphs. - Moved the tests from `test/test_n3_formula.py` into `test/test_serializers/test_serializer_n3.py`. - Include positive syntax tests from the N3 test suite that is smaller than 1024KB and that is not using new N3 syntax into round trip tests. This is mainly to check that there is no regressions after the changes made. Fixes: - RDFLib#1807 - RDFLib#1701
This patch fixes two issues with the N3 serializer: - The N3 serializer incorrectly considered a subject as already serialized if it has been serialized inside a quoted graph. - The N3 serializer does not consider that the predicate of a triple can also be a graph. Other changes included in this patch: - Changed `test.testutils.GraphHelper` to support nested/quoted graphs. - Moved the tests from `test/test_n3_formula.py` into `test/test_serializers/test_serializer_n3.py`. - Include positive syntax tests from the N3 test suite that is smaller than 1024KB and that is not using new N3 syntax into round trip tests. This is mainly to check that there is no regressions after the changes made. Fixes: - RDFLib#1807 - RDFLib#1701
This patch fixes two issues with the N3 serializer: - The N3 serializer incorrectly considered a subject as already serialized if it has been serialized inside a quoted graph. - The N3 serializer does not consider that the predicate of a triple can also be a graph. Other changes included in this patch: - Changed `test.testutils.GraphHelper` to support nested/quoted graphs. - Moved the tests from `test/test_n3_formula.py` into `test/test_serializers/test_serializer_n3.py`. - Include positive syntax tests from the N3 test suite that is smaller than 1024KB and that is not using new N3 syntax into round trip tests. This is mainly to check that there is no regressions after the changes made. Fixes: - #1807 - #1701
Version:
rdflib 6.1.1
python 3.8.10
I have a
test.py
:The output of this
test.py
has 2 possibilities.The first one (which is correct):
The second one (missing the triple parsed at the first time):
This strange bug appears in a completely random way. In order to count the "probability" of its occurrence, I wrote a loop like this:
Each execution gives a different result, like error= 8533, 5693, 437... As the
num
increase, the error rate do not converge to a specific value. Can't find any patterns.The text was updated successfully, but these errors were encountered: