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

No compression for CLI test ouputs #924

Closed
wants to merge 3 commits into from

Conversation

bayliffe
Copy link
Contributor

This PR proposes a simple method for turning off compression in the save wrapper using an imported environment variable. This will enable us to run the CLI tests without compression, which speeds them up by a factor of more than 2 (essentially reclaiming lost speed).

Note that a particular pylint check has been disabled for the test_save.py file as there is currently a bug in pylint which does not seem to be being fixed very rapidly: pylint-dev/pylint#1498

Testing:

  • Ran tests and they passed OK

@bayliffe bayliffe requested review from benfitzpatrick, arh89 and TomekTrzeciak and removed request for arh89 July 31, 2019 13:51
@@ -142,6 +144,10 @@ def save_netcdf(cubelist, filename):
Raises:
warning if cubelist contains cubes of varying dimensions.
"""
# To avoid compression SAVE_COMPRESSED=False can be exported to the
# environment. Defaults True if not set.
save_compressed = ast.literal_eval(os.getenv("SAVE_COMPRESSED", "True"))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I'd prefer a CLI flag really. If we are going to go for an environment variable, it probably should be IMPROVER_SAVE_UNCOMPRESSED and just test it's non-empty. We should also document it in all the CLI help... so it probably doesn't save any effort vs a CLI flag.

Copy link
Contributor

Choose a reason for hiding this comment

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

To me it also feels like reading environment within the save routine doesn't really belong there. Unfortunately, there doesn't seem any other easy way to implement that. CLI flag will force us for us add this to each and every CLI (because we have no way to handle common options across all CLIs).

A nice way to implement this could be with a context manager:

with improver.settings(netcdf_compression=False):
     ...

Unfortunately, we have no common point of entry into CLIs where we could add something like this.
CC @arh89, maybe you have some thoughts on this.

Copy link
Contributor

@arh89 arh89 Aug 5, 2019

Choose a reason for hiding this comment

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

(Agreed with @bayliffe about not doing this until after @neilCrosswaite's PR has gone in.)

Adding to all CLIs should be trivial, if we add to the COMPULSORY_ARGUMENTS in https://github.com/metoppv/improver/blob/master/lib/improver/argparser.py#L87, then all CLIs should pick them up. (NB: We'll still have to update all the BATS test outputs though, e.g help/nullargs)

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, if we wait until after Neil's work has gone in, we can trivially centralise the loading and saving, then we're golden 👍

@bayliffe
Copy link
Contributor Author

bayliffe commented Aug 5, 2019

Following discussion with @benfitzpatrick we will take an approach in which the call to save_netcdf is modified in each CLI to include the flag determining whether or not to use compression. This will require changes to all the CLIs and so will not be undertaken until @neilCrosswaite has completed his ongoing modifications to the CLIs.

@bayliffe bayliffe closed this Aug 5, 2019
@bayliffe bayliffe deleted the impro1307 branch December 11, 2019 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants