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

add import rioxarray where readers actually need them #2824

Merged
merged 3 commits into from
Jun 19, 2024

Conversation

ludwigVonKoopa
Copy link
Contributor

some readers use rasterio engine from xarray, but it actually use rioxarray in the backend, without stating it in the dependencies (see pydata/xarray#7831).

It should be a xarray problems, and in the PR they tend to agree to udpate the message without stating explicitly which exact dependency is problematic (which I understand).

So importing rioxarray in the reader file seems the best compromise : It complain with an ModuleNotFoundError, which is easier to understand why it doesn't work and how to correct that.

some readers use rasterio engine from xarray, but it actually use rioxarray in the backend, without stating it in the dependencies
@@ -31,6 +31,7 @@
import dask.array as da
import numpy as np
import rasterio
import rioxarray # noqa: F401, need by xarray with the engine rasterio
Copy link
Member

Choose a reason for hiding this comment

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

This comment uses a , to separate the rule from the description, but the other one uses a :. What is the recommended way of doing this (I assume it is supported)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, the , can be used when multiple rules should be ignored. i.e. : x=5 # noqa: E731,E123 So If I want to be fully correct I should stick with some dot . or simply a space.

Moreover, as stated in the documentation :

Contents before and after the # noqa: ... portion are ignored so multiple comments may appear on one line. Here are several examples:

# mypy requires `# type: ignore` to appear first
x = 5  # type: ignore  # noqa: ABC123
# can use to add useful user information to a noqa comment
y = 6  # noqa: ABC456  # TODO: will fix this later

pyproject.toml Outdated
@@ -66,7 +67,7 @@ gms5-vissr_l1b = ["numba"]
# Writers:
cf = ["h5netcdf >= 0.7.3"]
awips_tiled = ["netCDF4 >= 1.1.8"]
geotiff = ["rasterio", "trollimage[geotiff]"]
geotiff = ["rasterio", "rioxarray", "trollimage[geotiff]"]
Copy link
Member

Choose a reason for hiding this comment

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

Correct me if I'm wrong, but I'm 99% sure the geotiff writer does not use rioxarray.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exact, I saw rasterio so I had an urge to add rioxarray too

@ludwigVonKoopa
Copy link
Contributor Author

deleted rioxarray dependencies for geotiff writer, and standardized the noqa statement

Copy link

codecov bot commented Jun 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.94%. Comparing base (417c768) to head (76e6b82).
Report is 356 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2824      +/-   ##
==========================================
- Coverage   95.94%   95.94%   -0.01%     
==========================================
  Files         366      366              
  Lines       53613    53506     -107     
==========================================
- Hits        51441    51334     -107     
  Misses       2172     2172              
Flag Coverage Δ
behaviourtests 4.04% <0.00%> (+<0.01%) ⬆️
unittests 96.03% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@coveralls
Copy link

coveralls commented Jun 18, 2024

Pull Request Test Coverage Report for Build 9561417619

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 96.04%

Totals Coverage Status
Change from base Build 9513521871: 0.0%
Covered Lines: 51563
Relevant Lines: 53689

💛 - Coveralls

@djhoese djhoese merged commit 90d36d1 into pytroll:main Jun 19, 2024
18 of 19 checks passed
@djhoese
Copy link
Member

djhoese commented Jun 19, 2024

Thanks @ludwigVonKoopa!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants