Every xarray open pays the backend auto-detection cost - #695
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (88.9%) is below the target coverage (90.0%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #695 +/- ##
=======================================
+ Coverage 78.8% 79.0% +0.2%
=======================================
Files 41 41
Lines 9070 9070
Branches 1692 1692
=======================================
+ Hits 7143 7164 +21
+ Misses 1592 1570 -22
- Partials 335 336 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
xr.open_dataset/open_mfdatasetwithout an explicitengine=makesxarray auto-detect the backend by importing every registered
xarray.backendsentry point and asking each oneguess_can_open(). Theanalysis3 environment registers 37 of them, two of which — argopy's
argoand
erddapy— reach out to raw.githubusercontent.com on import. A Gadicompute node has no route there, so those imports block until they time
out.
The cost is paid once per process, at the first open that does not name
an engine. Measured at 38-46s per batch job, showing up in the phase
that happened to get there first — the Dask worker-sizing probe in
recommend_dask_config.Change
engine="netcdf4"added at 11 call sites acrossbase.py,executors/dask_config.py,utilities.py(x4),qc/cmip7.py,qc/plots.py(x2),ocean_supergrid.pyandderivations/calc_utils.py.This is not a new convention —
CMORiser.load_datasetalready pinned theengine in its
common_kwargsand in the fx branch; the rest had not beenbrought in line.
Every file opened is netCDF, verified rather than assumed:
NETCDF4NETCDF4_CLASSICNETCDF4_CLASSICresources/*.ncNETCDF4_CLASSICx3,NETCDF4x3Non-
.ncfiles in the archive (namelists, logs, STASH tables,config.yaml)are never opened — file discovery only matches
.nc. All four raw-datavariants were read both ways and compared: identical variables, dimensions,
global attributes and data.
Tests
New
tests/unit/test_xarray_engine_pinned.py, both mutation-checked:test_every_xarray_open_pins_the_enginewalks the package AST and failsif any
open_dataset/open_mfdataset/open_zarrcall omitsengine=.This is structural on purpose: "pinning some of them" is exactly the
failure mode arm B measured, so a test of one function would not have
caught it.
test_load_dataset_common_kwargs_pins_the_enginecloses the**kwargshole the structural check has to allow, by asserting
load_dataset'scommon_kwargsdict itself setsengine="netcdf4".Full suite: 2119 passed (2117 before this change).