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

BUG: xarray may leave a link to file open #887

Closed
jklenzing opened this issue Aug 19, 2021 · 5 comments · Fixed by #889
Closed

BUG: xarray may leave a link to file open #887

jklenzing opened this issue Aug 19, 2021 · 5 comments · Fixed by #889
Assignees
Labels

Comments

@jklenzing
Copy link
Member

Describe the bug
When loading xarray data via utils.load_netcdf, a link to the file may be left open on some windows systems. This creates issues in the unit tests observed in pysat/pysatModels#89

To Reproduce
Look through logs associated with pysat/pysatModels#92

Desktop (please complete the following information):

  • OS: Windows

Additional context
Not noticing problems in similar xarray instruments for pysatNASA, but could be slight version differences.

@jklenzing
Copy link
Member Author

Following up on this, I've compared the pysatNASA and pysatModels log for CI tests run recently on Windows with python 3.8. Both use the same versions of xarray (0.19.0), netCDF4 (1.5.7), and pysat (3.0.1). Not sure why the ICON xarray instruments work and the model xarray instruments fail. The pysatModels log does show a different version of the github actions runner (2.280.3 instead of 2.280.2).

Adding out.close() after the following load statements in the core package

pysat/pysat/utils/_core.py

Lines 404 to 407 in 3d33e81

if len(fnames) == 1:
out = xr.open_dataset(fnames[0])
else:
out = xr.open_mfdataset(fnames, combine='by_coords')

should fix the issue anywhere it occurs rather than fixing it after loading in other packages.

@jklenzing
Copy link
Member Author

Further testing with pysatNASA and the updated runner are working.

@rstoneback
Copy link
Collaborator

rstoneback commented Aug 19, 2021 via email

@jklenzing
Copy link
Member Author

Still not sure why it happens some places but not others. Not sure how to test for this, but so far it's fixed it wherever there's been a problem.

@jklenzing jklenzing self-assigned this Aug 24, 2021
@jklenzing jklenzing linked a pull request Aug 24, 2021 that will close this issue
10 tasks
@jklenzing
Copy link
Member Author

Closing with merge of #889.

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 a pull request may close this issue.

2 participants