-
Notifications
You must be signed in to change notification settings - Fork 13
Porting PyFDB to Pybind 11 #193
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
base: develop
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
91dfeff to
2be9698
Compare
Moved from str definition implementation to repr for having debugging information
Wildcard selection is now a boolean flag in the builder
Replaced with __init__(elem, *, _internal=False) and _internal needs to be set to True manually to construct internal objects.
5812380 to
21f1845
Compare
Works now with shutil and there is the option to zero-copy read into a buffer.
51f9ba9 to
1fea9bb
Compare
simondsmart
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more comments for you.
Please, where you have dealt with previous comments, can you resolve the relevant comments.
| z3fdb/index | ||
|
|
||
| :ref:`FDB <FDB_Introduction>` itself is part of `ECMWF <https://www.ecmwf.int>`__’s | ||
| high‑performance data infrastructure: it stores each GRIB message as a field, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The FDB is not restricted to GRIBs. I don't want this to be suggested in here.
I note that z3fdb does have ties to gridded data formats. That is a separate discussion.
docs/pyfdb/examples.rst
Outdated
|
|
||
| .. code-block:: python | ||
|
|
||
| builder = pyfdb.SelectionBuilder() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not convinced by this builder being the recommended way of doing this.
I don't understand why we can't have the typical case just being a
mars_selection = {
"class": "od",
...
"step": [x for x in range(1, 241)]
}
And hiding all of the grunge internally. That is not to say that we can't have a builder to make it easier to do more complex stuff - but I don't think it should be required.
We should probably also accept a simple string, and let metkit do its thing...
| fdb = pyfdb.FDB(fdb_config_path) | ||
| filename = data_path / "x138-300.grib" | ||
|
|
||
| fdb.archive(filename.read_bytes()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to have an example where the key is supplied along with the data.
| "time": "1800", | ||
| } | ||
|
|
||
| with fdb.retrieve(selection) as data_handle: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the context manager doing here? What happens when we leave the managed section.
I was expecting context managers on the archive pathway, but this is less obvious.
| URI[scheme=toc,name=/<path-to-db-store>/ea:0001:oper:20200101:1800:g]. | ||
|
|
||
|
|
||
| You can see that the ``ControlIdentifier`` with value ``4`` is active for the given entry of the ``FDB``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Erm, I see the thumbs up, but not that anything has changed.
| @@ -0,0 +1,148 @@ | |||
| from pyfdb.pyfdb_type import MarsSelectionMapper | |||
|
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be removed.
| @@ -0,0 +1,181 @@ | |||
| from pyfdb import FDB | |||
|
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about range selections? Lists where there isn't data. Lists that select a subset of what is present?
| from pyfdb.pyfdb_type import WildcardMarsSelection | ||
|
|
||
|
|
||
| def test_index_axis_string(read_only_fdb_setup): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add some tests where you explicitly construct the IndexAxis object, and test equality with the returned value from the fdb.axes() call.
| def test_from_selection(): | ||
| fdb_tool_request = FDBToolRequest.from_mars_selection({"key-1": "value-1"}) | ||
|
|
||
| print(fdb_tool_request) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't test anything except for that the code doesn't crash...
| key_values=selection, all=isinstance(selection, WildcardMarsSelection) | ||
| ) | ||
|
|
||
| def ____repr__(self) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't look right (quadruple '_')
Description
I'm aware that this is a somewhat mid-sized PR 😉 It's also a complete rewrite with tests and documentation.
Porting FDB to PyBind11, making the Python-API more user-friendly and introducing tests for the API layer which are testing core functionality of the FDB in an ephemeral FDB setup.
Documentation is added to the code base as well as the sphinx generated side.
The coverage was tested and is close to 100% testing all provided use-cases and functionalities.
For now I keep this PR in WIP status and I'm open to discuss Implementation details.
Notes for reviewers:
Contributor Declaration
By opening this pull request, I affirm the following:
🌈🌦️📖🚧 Documentation FDB 🚧📖🌦️🌈
https://sites.ecmwf.int/docs/dev-section/fdb/pull-requests/PR-193