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

Move absolute path finder from open_mfdataset to own function #7968

Merged
merged 9 commits into from
Jul 10, 2023

Conversation

Illviljan
Copy link
Contributor

@Illviljan Illviljan commented Jul 9, 2023

A simple refactor to make it easier to retrieve the proper paths that open_mfdataset uses and passes on the engine.

I've been thinking how to make use of DataTree and one idea I wanted to try was:

  • Open file (using _find_absolute_path).
  • Get all groups in the file.
  • For each group run xr.open_mfdataset(..., group=group)

@Illviljan Illviljan changed the title Move absolute path finder to own function Move absolute path finder from open_mfdataset to own function Jul 9, 2023
@Illviljan Illviljan marked this pull request as ready for review July 9, 2023 15:16
xarray/backends/common.py Outdated Show resolved Hide resolved
else:
paths = sorted(glob(_normalize_path(paths)))
elif isinstance(paths, os.PathLike):
paths = [os.fspath(paths)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know that this is just moved from the previous location, but is there a reason why we don't convert to absolute path here and below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure, it's a little odd to me as well.

I haven't really felt the need for os.PathLike in my normal usage so I don't have much experience with that part though.

Co-authored-by: Michael Niklas  <mick.niklas@gmail.com>
@Illviljan Illviljan added the plan to merge Final call for comments label Jul 9, 2023
@TomNicholas
Copy link
Member

@Illviljan see also xarray-contrib/datatree#51

@Illviljan
Copy link
Contributor Author

@TomNicholas I've found the current open_datatree implementations too focused on zarr and netcdf. Which is fine, it's the most popular after all.
But I want to make use of custom engines so I'll play around on my side for a while.

@Illviljan Illviljan merged commit 554285b into pydata:main Jul 10, 2023
25 of 27 checks passed
dcherian added a commit to dcherian/xarray that referenced this pull request Jul 16, 2023
* main:
  Remove hue_style from plot1d docstring (pydata#7925)
  Add new what's new section (pydata#7986)
  Release summary for v2023.07.0 (pydata#7979)
  Improve explanation in example "Working with Multidimensional Coordinates" (pydata#7984)
  Fix typo in zarr.py (pydata#7983)
  Examples added to docstrings  (pydata#7936)
  [pre-commit.ci] pre-commit autoupdate (pydata#7973)
  Skip broken tests on python 3.11 and windows (pydata#7972)
  Use another repository for upstream testing (pydata#7970)
  Move absolute path finder from open_mfdataset to own function (pydata#7968)
  ensure no forward slashes in names for HDF5-based backends (pydata#7953)
  Chunked array docs (pydata#7951)
  [pre-commit.ci] pre-commit autoupdate (pydata#7959)
  manually unshallow the repository on RTD (pydata#7961)
  Update minimum version of typing extensions in pre-commit (pydata#7960)
  Docstring examples (pydata#7881)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants