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 parser: do not create formulas if the Turtle mode is activated #1142

Merged
merged 3 commits into from Sep 17, 2020

Conversation

Tpt
Copy link
Contributor

@Tpt Tpt commented Aug 14, 2020

Fixes #1141

Proposed Changes

  • Do not attempt to build a default formula if the Turtle mode is activated

@Tpt
Copy link
Contributor Author

Tpt commented Aug 14, 2020

Hi @ashleysommer! Thank you for your feedback and sorry for the buggy change.

I have added a test to ensure there is no regression.
Indeed, having a null context was creating a blank node Id collision problem.
I have fixed it. Hopefully all tests should pass now.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 75.855% when pulling 328fab1 on Tpt:#1141 into 89cb369 on RDFLib:master.

@@ -1745,7 +1746,7 @@ def newBlankNode(self, arg=None, uri=None, why=None):
return arg.newBlankNode(uri)
elif isinstance(arg, Graph) or arg is None:
self.counter += 1
bn = BNode("n" + str(self.counter))
bn = BNode("n%sb%s" % (self.uuid, self.counter))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to have to look into this a little deeper. I don't know if adding a UUID to the RDFSink is the best way to approach this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UUID usage is what is currently done internally by the formula blank node generator

# with formula
graph = Graph()
self.assertTrue(graph.store.formula_aware)
graph.load(BytesIO(file), format=format)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just FYI, in RDFLib 5.1.0 the graph.load() method will be deprecated as part of the Graph API cleanup process, and in 6.0.0 load() will be removed.
You will need to use graph.parse() instead. In this case where file is a string with the RDF data, use graph.parse(data=file).

Copy link
Contributor Author

@Tpt Tpt Aug 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok! Thank you! I'll fix it if the global PR design is accepted

@ashleysommer
Copy link
Contributor

ashleysommer commented Aug 14, 2020

@Tpt this PR will require further and more thorough review by the maintainers team. The reason being this section of code you're working on is literally 15 to 20 years old, hasn't changed in a very long time, and used by hundreds of thousands of people every day for critical processes. Every tiny little change here could cause unforeseen problems in places we haven't thought of.

@Tpt
Copy link
Contributor Author

Tpt commented Aug 17, 2020

Thank you for the review! Indeed, there is a significant risk of unforeseen problem. I found the blank node ID generation one but there might be others.

@ashleysommer
Copy link
Contributor

@Tpt
Sorry about the long delay in reviewing this.
I've done some extensive testing on this today, and I'm happy to say that its all good!
We can merge this, and this will open up the possibility of having more simplified store backends as Turtle Parser targets.

@ashleysommer ashleysommer merged commit 5fb74b4 into RDFLib:master Sep 17, 2020
@Tpt Tpt deleted the #1141 branch September 17, 2020 14:42
@Tpt
Copy link
Contributor Author

Tpt commented Sep 17, 2020

@ashleysommer Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Turtle parser fails when a store without formula support is used
3 participants