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

Fix #280: Added container.py for adding container class and seq, alt and bag as it's subclasses #997

Merged
merged 97 commits into from
May 25, 2020

Conversation

kushagr08
Copy link
Contributor

Adding container functionality with subclasses rdf:seq, rdf: alt and rdf:bag to RDFLib. This is in accordance with as proposed by me in the discussion of issue 280 of RDFLib.

mwatts15 and others added 6 commits March 16, 2020 19:20
- Also, fixing batching
- unittest.mock is not available in Python 2.7
Adding container functionality with subclasses rdf:seq, rdf: alt and rdf:bag to RDFLib
@coveralls
Copy link

coveralls commented Apr 7, 2020

Coverage Status

Coverage decreased (-0.2%) to 75.704% when pulling bc213dc on kushagr08:master into 604d63e on RDFLib:master.

@kushagr08 kushagr08 changed the title Add files via upload Fix #280: Added container.py for adding container class and seq, alt and bag as it's subclasses Apr 7, 2020
rdflib/container.py Outdated Show resolved Hide resolved
update as per comment 1 of pull request
@kushagr08 kushagr08 requested a review from niklasl April 8, 2020 06:35
rdflib/container.py Outdated Show resolved Hide resolved
@niklasl
Copy link
Member

niklasl commented Apr 8, 2020

I'm not sure if we have settled on a coding standard, but (mainly) following PEP8 is prudent, e.g. by running code through the pep8 tool. I haven't done so, but I suspect some things'll crop up, e.g. consistently surrounding operators (= assignment and == comparison) with single spaces, which seemed a bit inconsistent here.

Updated code as per pep8 standards
rdf: Seq correction made in Seq class
@kushagr08
Copy link
Contributor Author

@niklasl
I have updated the code in accordance with PEP8 standards.

@kushagr08 kushagr08 requested a review from niklasl April 8, 2020 13:09
@nicholascar nicholascar linked an issue Apr 10, 2020 that may be closed by this pull request
@kushagr08
Copy link
Contributor Author

@niklasl
Could you give a further update (review) on the third commit made by me so that I can work forward accordingly?

Comment on lines 26 to 31
pred_uri = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'
container_uri = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
container_uri += str(self._type)
container = self.uri
self.graph.add((container, URIRef(pred_uri), URIRef(container_uri)))#adding triple corresponding to container type

# adding triple corresponding to container type
self.graph.add((container, URIRef(pred_uri), URIRef(container_uri)))
Copy link
Member

Choose a reason for hiding this comment

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

You could use from rdflib.namespace import RDF in the import section, and then use RDF.type here (preferably directly in the call to self.graph.add to avoid declaring this once-used pred_uri variable), and then either use RDF[typee], or (IMHO preferably) pass RDF.Bag in the call from Bag, RDF.Seq from Seq and RDF.Alt from Alt.

(Also, I think type_ is preferred over typee (which sounds like "the thing to be typed". But that's probably nit-picking. It would be good to have a convention for the name of a type in Python though (I commonly use rtype in Python-code dealing with RDF... Anyone have an opinion on 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.

@niklasl
I have made the required changes.

@niklasl
Copy link
Member

niklasl commented Apr 10, 2020

@kushagr08 The changes look good, and I'll chime in on this and possibly other pull requests when I can. But I cannot be counted on as an official reviewer or proper representative of RDFLib at this time I'm afraid, as I do this on my spare time and am currently bound to taking care of my daughter who is very ill.

@kushagr08
Copy link
Contributor Author

@niklasl
Thanks
Since you have conveyed to me about your limited availability, I would humbly like to request you if you could add one or two other RDFLib members as reviewers for this pull request.

I am making this request since I am contributing to this open-source project as part of a course on Semantic Web at my university ( IIIT Delhi, India ). Therefore, I would really appreciate if I could get quick reviews on a daily basis, so that my work proceeds at a steady pace.

@kushagr08 kushagr08 requested a review from niklasl April 10, 2020 17:52
@white-gecko white-gecko added this to the rdflib 5.1.0 milestone Apr 10, 2020
@niklasl
Copy link
Member

niklasl commented Apr 10, 2020

@kushagr08 I understand. Alas, I'm not sure that anyone has the capacity to assist you as reviewers in such a prompt fashion. Mostly people step up if they can manage the time (or some time, as I did).

@kushagr08
Copy link
Contributor Author

@niklasl
In that case, I would request you to review my contributions whenever it is possible for you according to your comfort, convenience and availability.

All other members of the RDFLib organization are also welcome to join in as per their availability and convenience.

Thanking You Sincerely and Best Regards,
Kushagr Arora

@kushagr08
Copy link
Contributor Author

@nicholascar
As suggested by you, I have put all tests as unit tests in test/test_container.py. I request you to review my work. Thanks.

@nicholascar
Copy link
Member

Hi @kushagr08, thanks for making those changes. I'll just see PR #1051 through first, since it removes all Python2 references, and then I'll merge the result into this, test and merge this PR back in.

@nicholascar
Copy link
Member

I've just enhanced code documentation and indicated in the main Sphinx docs that this class and Collection exist as convenient ways of making RDF data.

@nicholascar nicholascar merged commit 9c064ac into RDFLib:master May 25, 2020
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.

Add method for adding new Seq objects