openmethane / setup-wrf

Setup the WRF model
0 stars 0 forks source link

Switch from argparse to click #32

Closed crdanielbusch closed 20 hours ago

crdanielbusch commented 1 week ago

Description

Change the command line interface from the argparse library to click.

Checklist

Please confirm that this pull request has done the following:

Notes

lewisjared commented 1 week ago

Now would be a good time to move the content of setup_for_wrf into a function

crdanielbusch commented 1 week ago

This is ready to be reviewed @lewisjared.

Thanks for the tip. I wasn't sure if it was necessary to move everything into a function. But it looks much better now.

I've started to write tests for the click implementation, but it turned out to be rather difficult. In the tests, we would need to run the function that takes the command line arguments and runs the whole script. But running the whole script does not really work locally. Do you have another idea how to tests this? Or maybe click tests are not super important here?

lewisjared commented 1 week ago

I've started to write tests for the click implementation, but it turned out to be rather difficult.

Take a look at tests/integration/sat_data/test_fetch.py in the openmethane project. That shows how you can run click cli tools without subprocess shenanigans.

You are right though that testing a large single function app like this is hard. Often the CLI part of the codebase is a very thin function which calls out to other functions. That function is just responsible for moving the command line arguments to the function.