aiidateam / disk-objectstore

An implementation of an efficient "object store" (actually, a key-value store) writing files on disk and not requiring a running server
https://disk-objectstore.readthedocs.io
MIT License
16 stars 8 forks source link

Replacing `os.path` with `pathlib`, and replace returned dictionaries with dataclasses #153

Closed giovannipizzi closed 1 year ago

giovannipizzi commented 1 year ago

Note that in the process I changed the signature of some of the functions to get (or return) only pathlib.Path objects rather than strings, where appropriate. Therefore, this PR is backward-incompatible and the next release should be a new 0.7, or even directly 1.0. However, for convenience, the main Container.__init__ method accepts both a string or a Path object, for convenience. Fixes #149

In addition, returned dicts are replaced with dataclasses. This is instead done in a backward-compatible way, where the dataclass also provides a __getitem__ method so you can use it as a dictionary. If you want proper type checking, you should instead use it calling it as a method. Fixes #150

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 99.21% and project coverage change: -0.06 :warning:

Comparison is base (5ba9316) 99.94% compared to head (58b7d91) 99.89%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #153 +/- ## ========================================== - Coverage 99.94% 99.89% -0.06% ========================================== Files 8 9 +1 Lines 1862 1904 +42 ========================================== + Hits 1861 1902 +41 - Misses 1 2 +1 ``` | [Impacted Files](https://app.codecov.io/gh/aiidateam/disk-objectstore/pull/153?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiidateam) | Coverage Δ | | |---|---|---| | [disk\_objectstore/dataclasses.py](https://app.codecov.io/gh/aiidateam/disk-objectstore/pull/153?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiidateam#diff-ZGlza19vYmplY3RzdG9yZS9kYXRhY2xhc3Nlcy5weQ==) | `97.43% <97.43%> (ø)` | | | [disk\_objectstore/cli.py](https://app.codecov.io/gh/aiidateam/disk-objectstore/pull/153?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiidateam#diff-ZGlza19vYmplY3RzdG9yZS9jbGkucHk=) | `100.00% <100.00%> (ø)` | | | [disk\_objectstore/container.py](https://app.codecov.io/gh/aiidateam/disk-objectstore/pull/153?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiidateam#diff-ZGlza19vYmplY3RzdG9yZS9jb250YWluZXIucHk=) | `99.88% <100.00%> (-0.01%)` | :arrow_down: | | [disk\_objectstore/database.py](https://app.codecov.io/gh/aiidateam/disk-objectstore/pull/153?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiidateam#diff-ZGlza19vYmplY3RzdG9yZS9kYXRhYmFzZS5weQ==) | `100.00% <100.00%> (ø)` | | | [disk\_objectstore/examples/example\_objectstore.py](https://app.codecov.io/gh/aiidateam/disk-objectstore/pull/153?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiidateam#diff-ZGlza19vYmplY3RzdG9yZS9leGFtcGxlcy9leGFtcGxlX29iamVjdHN0b3JlLnB5) | `100.00% <100.00%> (ø)` | | | [disk\_objectstore/examples/profile\_zeros.py](https://app.codecov.io/gh/aiidateam/disk-objectstore/pull/153?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiidateam#diff-ZGlza19vYmplY3RzdG9yZS9leGFtcGxlcy9wcm9maWxlX3plcm9zLnB5) | `100.00% <100.00%> (ø)` | | | [disk\_objectstore/utils.py](https://app.codecov.io/gh/aiidateam/disk-objectstore/pull/153?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiidateam#diff-ZGlza19vYmplY3RzdG9yZS91dGlscy5weQ==) | `100.00% <100.00%> (ø)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.