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

MNT: Move cartopy feature download script into the package #2263

Merged
merged 1 commit into from Jan 10, 2024

Conversation

greglucas
Copy link
Contributor

Move it from the tools directory into the feature module and make it an executable module by calling it main.py

It can be invoked with python -m cartopy.feature.download now.

Does this location make sense? This adds a new download module so that the execution has download in the name which I think helps with discoverability/readability (python -m cartopy.feature -h isn't as readable IMO if we put __main__.py in the top-level), I'm open to other suggestions as well.

closes #2227

Rationale

Implications

@@ -55,9 +55,6 @@ ows = ["OWSLib>=0.20.0", "pillow>=6.1.0"]
plotting = ["pillow>=6.1.0", "scipy>=1.3.1"]
test = ["pytest>=5.1.2", "pytest-mpl>=0.11", "pytest-xdist", "pytest-cov", "coveralls"]

[project.scripts]
Copy link
Contributor

Choose a reason for hiding this comment

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

In addition to the Why not leaving it also as executable script that is installed with the package, typically named cartopy_feature_download? Maybe you must declare a main function in the __main__ module for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I think you're right, we need to define a function that can be called from the script for that. I moved the content in the if block inside a separate main() function like you suggested.

Now you can access this script via: python -m cartopy.feature.download -h or cartopy_feature_download gshhs physical --dry-run

I guess this just brings up the question of whether this installed script is desired or not. I don't have a major preference either way, but would probably slightly lean towards not including it in the scripts section since it is not a critical piece of cartopy. But, it looks like you @stefraynaud were the one that added this as an installation piece, so maybe it is useful for you as a standalone script? Previously, I think it made sense because it was only accessible via a git clone of the repository to access the tools directory, but now you can execute the module which is installed with the package as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Installing these data once for all is useful when used for instance on a computer node that has no internet access.
I had to solve the problem for several people that don't necessarily git clone cartopy.
It is not critical because of cartopy_offlinedata conda package but not everyone has their own python installation to add this package.
Making it easily accessible as an executable is not difficult once the main function is declared. Then we just have to say "execute cartopy_feature_download -h from whereever your are".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree with the first part on this function being useful without git cloning.

My second part was just suggesting to now tell users from wherever you are type: python -m cartopy.feature.download -h

But, I'm fine either way with including the install script, so left it in for now.

Move it from the tools directory into the feature module and make
it an executable module by calling it __main__.py

It can be invoked with `python -m cartopy.feature.download` now.
Copy link
Member

@QuLogic QuLogic left a comment

Choose a reason for hiding this comment

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

Seems reasonable to me.

@QuLogic QuLogic merged commit 5e44939 into SciTools:main Jan 10, 2024
22 checks passed
@greglucas greglucas deleted the move-feature-download-script branch January 10, 2024 15:51
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.

Don't use generic feature_download executable name
3 participants