-
Notifications
You must be signed in to change notification settings - Fork 54
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
Improved Beam Opener PTransforms #375
Improved Beam Opener PTransforms #375
Conversation
67c4ccd
to
d0382f0
Compare
3054cf2
to
4cc71bb
Compare
7fb2d65
to
ee985ac
Compare
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.
LGTM, Ryan! Just one small question for you below re: use of thing
as parameter name.
Of course this is one of those large restructures that's hard to review in too great of detail, but the structure does make a lot sense to me, and seems like a clear template for how to proceed. Thanks for digging so far into the Beam best practices, to establish this foundation on solid footing.
Also totally agree that conftest.py
is due for a revisit. Your comment about pytest making Byzantine layers of combinations too easy made me laugh. So true! 😅
pangeo_forge_recipes/openers.py
Outdated
|
||
|
||
def open_with_xarray( | ||
thing: Union[OpenFileType, 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.
If you like the generality of thing
as a parameter name, I'm open to it, but my gut reaction is that this is a somewhat opaque name, and perhaps something more descriptive would make the code more self-documenting. Even, obj_to_open
or the like?
Thanks! The new parameter name is much more intuitive, imo. |
Merging this so we can move forward. Alex, there will be many more opportunities to review if you are game. 😉 |
I'll try to catch up when I can! I just got back from my vacation :) |
This PR tries to provide a template that we can use to efficiently add more and more beam PTransforms to pangeo_forge_recipes (see #376 for more context).
New public API members
It implements two PTransforms:
OpenURLWithFSSpec
: - Open indexed string-based URLs with fsspecOpenWithXarray
: - Open indexed items with Xarray. Accepts either fsspec open-file-like objectsor string URLs that can be passed directly to Xarray.
In addition, it exposes two functions in a new module called
openers
. The PTransforms are lightweight wrappers around these.open_url
- Open a string-based URL with fsspec.open_with_xarray
- Open item with Xarray.All of these functions and transforms are fully type hinted, and the test pipelines are run with type checking.
Improved Testing
Along the way, I made some improvements to the test suit which I hope are creating a more solid foundation for moving forward, towards the goal of more flexible openers. Some of the changes I made are:
make_netcdf_local_paths
->make_local_paths
- this fixture is now parametrized to create NetCDF4, NetCDF3, and Zarr inputs. This gives us much better coverage of different possible inputs to our recipes. One downside is thatconftest.py
is now extremely large and quite hard to follow. We should revisit this once the refactor is farther along and perhaps try to cut some fat.Documentation
So far, I am just creating API docs. They can be previewed here: https://pangeo-forge--375.org.readthedocs.build/en/375/pangeo_forge_recipes/api_reference.html#processing-functions
Questions
OTypeHints[inputs=Tuple[Index, str], outputs=Tuple[Index, OpenFileType]
.Do you know of any way to discover these and inject them into the docs?