Skip to content

Added argument ignore_unrecognised to tripper.convert()#247

Merged
jesper-friis merged 7 commits intomasterfrom
ignore_unrecognised
Sep 3, 2024
Merged

Added argument ignore_unrecognised to tripper.convert()#247
jesper-friis merged 7 commits intomasterfrom
ignore_unrecognised

Conversation

@jesper-friis
Copy link
Contributor

@jesper-friis jesper-friis commented Sep 2, 2024

Description

Added argument ignore_unrecognised to tripper.convert().

Question: One could consider to set ignore_unrecognised=True by default. It will be a small change in behavior, but more user friendly. I think that would be wise change.

Type of change

  • Bug fix and code cleanup
  • New feature
  • Documentation update
  • Testing

Checklist for the reviewer

This checklist should be used as a help for the reviewer.

  • Is the change limited to one issue?
  • Does this PR close the issue?
  • Is the code easy to read and understand?
  • Do all new feature have an accompanying new test?
  • Has the documentation been updated as necessary?
  • Is the code properly tested?

@codecov
Copy link

codecov bot commented Sep 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.40%. Comparing base (dcc8d43) to head (a30c968).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #247      +/-   ##
==========================================
+ Coverage   78.35%   78.40%   +0.05%     
==========================================
  Files          18       18              
  Lines        1723     1723              
==========================================
+ Hits         1350     1351       +1     
+ Misses        373      372       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@francescalb
Copy link
Contributor

I have trouble seeing how to use this function prperly. Could you add some examples?
The reason that I am asking for this as a part of this PR is that it is hard to really see what is happening. Especially since a test has not been added or updated.

@jesper-friis
Copy link
Contributor Author

jesper-friis commented Sep 2, 2024

I have trouble seeing how to use this function prperly. Could you add some examples? The reason that I am asking for this as a part of this PR is that it is hard to really see what is happening. Especially since a test has not been added or updated.

An example use case:

from tripper import DCTERMS, Literal, Triplestore
from tripper.convert import load_container, save_container

ts = Triplestore("rdflib")
dataset = {"a": 1, "b": 2}
save_container(ts, dataset, ":data_indv")

# Add additional context to our data individual
ts.add((":data_indv", DCTERMS.title, Literal("My wonderful data")))

data = load_container(ts, ":data_indv")  # <-- this will raise an exception complaining about DCTERMS.title is not a recognised key

data = load_container(ts, ":data_indv", ignore_unrecognised=True)  # <-- this will works (ignores ECTERMS.title)

@jesper-friis
Copy link
Contributor Author

The example is now added to module docstring. It is checked by doctest.

Copy link
Contributor

@francescalb francescalb left a comment

Choose a reason for hiding this comment

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

very nice.

@jesper-friis jesper-friis merged commit b615596 into master Sep 3, 2024
@jesper-friis jesper-friis deleted the ignore_unrecognised branch September 3, 2024 07:35
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.

2 participants