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

Do not pass filter_parameters to the filehandler creation #675

Merged
merged 7 commits into from Mar 26, 2019

Conversation

mraspaud
Copy link
Member

@mraspaud mraspaud commented Mar 25, 2019

  • Tests added
  • Tests passed
  • Passes git diff origin/master -- "*py" | flake8 --diff

@mraspaud mraspaud self-assigned this Mar 25, 2019
@mraspaud mraspaud marked this pull request as ready for review March 26, 2019 10:01
@mraspaud mraspaud requested a review from djhoese March 26, 2019 10:01
@coveralls
Copy link

coveralls commented Mar 26, 2019

Coverage Status

Coverage increased (+0.03%) to 78.691% when pulling 58e9d64 on mraspaud:fix-filter-fh into e3f707d on pytroll:master.

@codecov
Copy link

codecov bot commented Mar 26, 2019

Codecov Report

Merging #675 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #675      +/-   ##
==========================================
+ Coverage   78.66%   78.69%   +0.02%     
==========================================
  Files         138      138              
  Lines       20356    20390      +34     
==========================================
+ Hits        16013    16045      +32     
- Misses       4343     4345       +2
Impacted Files Coverage Δ
satpy/scene.py 89.9% <100%> (+0.39%) ⬆️
satpy/readers/__init__.py 93.67% <100%> (-0.88%) ⬇️
satpy/tests/test_scene.py 99.48% <100%> (+0.01%) ⬆️
satpy/readers/avhrr_l1b_gaclac.py 8.33% <0%> (-0.18%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e3f707d...58e9d64. Read the comment docs.

@@ -709,6 +709,9 @@ def load_readers(filenames=None, reader=None, reader_kwargs=None,
"""
reader_instances = {}
reader_kwargs = reader_kwargs or {}
reader_kwargs_without_filter = reader_kwargs.copy()
reader_kwargs_without_filter.pop('filter_parameters', None)
Copy link
Member

Choose a reason for hiding this comment

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

You could do:

filter_parameters = reader_kwargs.pop('filter_parameters', None)

and pass reader_kwargs and filter_parameters to the reader creation, but only reader_kwargs to the file handlers. Saves a copy, but not a big deal.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, so, we need to decide, what are we rooting for ? filter_parameters as standalone parameters or part of reader_kwargs?

Copy link
Member

Choose a reason for hiding this comment

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

I was just making a suggestion to clean up the code. It is the same interface on the reader and to this load_readers function. I'm saying you don't need to copy the dictionary if you pass filter_parameters explicitly:

filter_parameters = reader_kwargs.pop('filter_parameters', None)
reader = reader_cls(filter_parameters=filter_parameters, **reader_kwargs)
...
reader.create_filehandlers(**reader_kwargs)

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, agreed, but I'd like to take this opportunity to clarify things :) what is the "right" way ? This way we could maybe add a deprecation warning or something ?

Copy link
Member

Choose a reason for hiding this comment

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

I think in the long-long run we remove the ability to filter things through load_readers (and through that the Scene.__init__.

In the short term the user should be specifying filter_parameters as a separate kwarg but the Scene.__init__ already has a deprecation warning for this and moves start_time/end_time/area to filter_parameters for the user. If you want to move filter_parameters outside of reader_kwargs and make it a separate/explicit kwarg I guess I'd be ok with that and maybe would prefer that.

Copy link
Member

@djhoese djhoese left a comment

Choose a reason for hiding this comment

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

I think removing filter_parameters from the docstring may have been the opposite of what I suggested, but given that the long term decision is to probably remove all filtering from reader creation it doesn't really matter. This is an internal function right now anyway.

Also, given the need for this bug fix in master I don't want to hold this up any longer.

@djhoese djhoese merged commit 7a858c5 into pytroll:master Mar 26, 2019
@mraspaud mraspaud deleted the fix-filter-fh branch April 10, 2019 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants