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

N3 serializer "randomly" omits triple #1807

Closed
ghost opened this issue Apr 13, 2022 · 3 comments · Fixed by #1858
Closed

N3 serializer "randomly" omits triple #1807

ghost opened this issue Apr 13, 2022 · 3 comments · Fixed by #1858
Assignees
Labels
bug Something isn't working format: N3 Related to N3 format. serialization Related to serialization.

Comments

@ghost
Copy link

ghost commented Apr 13, 2022

There seems to be an issue with the notation3 serializer randomly omitting to serialize triples.

Given the following test created in test/test_n3_formula.py ...

import pytest
import rdflib

test_n3 = """@prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix : <http://test/> .
{:a :b :c;a :foo} => {:a :d :c,?y} .
_:foo a rdfs:Class .
:a :d :c ."""

@pytest.mark.xfail(reason="N3 serializer randomly omits triple")
def test():
    graph1 = rdflib.Graph()
    graph1.parse(data=test_n3, format="n3")

    """
    >>> sorted(list(graph1))
    [
        (
            rdflib.term.BNode('fde0470d85a044b6780f0c6804b119063b1'),
            rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'),
            rdflib.term.URIRef('http://www.w3.org/2000/01/rdf-schema#Class')
        ),
        (
            rdflib.term.URIRef('http://test/a'),
            rdflib.term.URIRef('http://test/d'),
            rdflib.term.URIRef('http://test/c')
        ),
        (
            <Graph identifier=_:Formula2 (<class 'rdflib.graph.QuotedGraph'>)>,
            rdflib.term.URIRef('http://www.w3.org/2000/10/swap/log#implies'),
            <Graph identifier=_:Formula3 (<class 'rdflib.graph.QuotedGraph'>)>
        )
    ]
    """

    graph2 = rdflib.Graph()
    graph2.parse(data=graph1.serialize(format="n3"), format="n3")
    assert (
        rdflib.term.URIRef('http://test/a'),
        rdflib.term.URIRef('http://test/d'),
        rdflib.term.URIRef('http://test/c')
    ) in graph2

Sample run_test.py results ...

(rdflib) $ ./run_tests.py test/test_n3_formula.py 
Running pytest with: ["test/test_n3_formula.py"]
============================================ test session starts =============================================
platform linux -- Python 3.8.10, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: rdflib, configfile: tox.ini
plugins: subtests-0.6.0, cov-3.0.0
collected 1 item                                                                                             

test/test_n3_formula.py::test XFAIL (N3 serializer randomly omits triple)                              [100%]

============================================= 1 xfailed in 0.02s =============================================
(rdflib) $ ./run_tests.py test/test_n3_formula.py 
Running pytest with: ["test/test_n3_formula.py"]
============================================ test session starts =============================================
platform linux -- Python 3.8.10, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: rdflib, configfile: tox.ini
plugins: subtests-0.6.0, cov-3.0.0
collected 1 item                                                                                             

test/test_n3_formula.py::test XPASS (N3 serializer randomly omits triple)                              [100%]

============================================= 1 xpassed in 0.01s =============================================
@aucampia aucampia added the bug Something isn't working label Apr 13, 2022
@aucampia
Copy link
Member

happy to add this to the test suite, I tried making a variant test for this but rdfpipe does not produce valid nquads form this (even if I replace ?y with :y), which is maybe another bug, but I'm actually a bit skittish on n3, and I think maybe this just cannot be encoded as nquads

@ghost
Copy link
Author

ghost commented Apr 13, 2022

happy to add this to the test suite, I tried making a variant test for this but rdfpipe does not produce valid nquads form this (even if I replace ?y with :y), which is maybe another bug, but I'm actually a bit skittish on n3, and I think maybe this just cannot be encoded as nquads

Feel free to add to the test suite and yes, you are correct formulae are specific to notation3 format.

@aucampia
Copy link
Member

Fairly sure this is related to #1701

@aucampia aucampia self-assigned this Apr 19, 2022
@aucampia aucampia added serialization Related to serialization. format: N3 Related to N3 format. labels Apr 19, 2022
aucampia added a commit to aucampia/rdflib that referenced this issue Apr 23, 2022
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
aucampia added a commit to aucampia/rdflib that referenced this issue Apr 23, 2022
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
aucampia added a commit to aucampia/rdflib that referenced this issue Apr 23, 2022
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
aucampia added a commit to aucampia/rdflib that referenced this issue Apr 23, 2022
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
aucampia added a commit to aucampia/rdflib that referenced this issue Apr 23, 2022
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
aucampia added a commit to aucampia/rdflib that referenced this issue Apr 23, 2022
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
@aucampia aucampia linked a pull request Apr 23, 2022 that will close this issue
4 tasks
aucampia added a commit to aucampia/rdflib that referenced this issue Apr 24, 2022
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
aucampia added a commit to aucampia/rdflib that referenced this issue Apr 24, 2022
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
aucampia added a commit to aucampia/rdflib that referenced this issue Apr 24, 2022
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
aucampia added a commit to aucampia/rdflib that referenced this issue Apr 30, 2022
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
aucampia added a commit to aucampia/rdflib that referenced this issue May 3, 2022
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
aucampia added a commit to aucampia/rdflib that referenced this issue May 4, 2022
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
aucampia added a commit to aucampia/rdflib that referenced this issue May 12, 2022
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
aucampia added a commit that referenced this issue May 16, 2022
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
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: N3 Related to N3 format. serialization Related to serialization.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant