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

feat(generate_classes): create a command-line interface #1912

Merged
merged 1 commit into from
Aug 16, 2023

Conversation

mwtoews
Copy link
Contributor

@mwtoews mwtoews commented Aug 10, 2023

This is a simple command-line interface for generate_classes() using the -m switch method with argparse, which is cleaner than using the -c command switch approach. E.g., compare:

- python -c 'import flopy; flopy.mf6.utils.generate_classes(ref="develop", backup=False)'
+ python -m flopy.mf6.utils.generate_classes --ref develop --no-backup

Built-in help is shown with python -m flopy.mf6.utils.generate_classes -h.

At this time, it is not added to [project.scripts] (like get-modflow) since this is generally a developer feature, not a user feature.

Also, not sure if this was overlooked from #1907, but the defaults to generate_classes() would always show:

DeprecationWarning: branch is deprecated, use ref instead

This is resolved by swapping these defaults to branch=None and ref="master".

Closes #1629

@mwtoews mwtoews requested a review from wpbonelli August 10, 2023 02:20
@codecov
Copy link

codecov bot commented Aug 10, 2023

Codecov Report

Merging #1912 (2127262) into develop (7237026) will decrease coverage by 0.1%.
The diff coverage is 19.0%.

@@            Coverage Diff            @@
##           develop   #1912     +/-   ##
=========================================
- Coverage     72.5%   72.5%   -0.1%     
=========================================
  Files          257     257             
  Lines        56276   56294     +18     
=========================================
+ Hits         40849   40853      +4     
- Misses       15427   15441     +14     
Files Changed Coverage Δ
flopy/mf6/utils/generate_classes.py 17.6% <19.0%> (+0.8%) ⬆️

@wpbonelli
Copy link
Member

wpbonelli commented Aug 10, 2023

Thanks @mwtoews I did overlook the defaults in 1907.

I wonder if this could see use beyond developers e.g. modelers beta testing unreleased versions of modflow6. Are there downsides to adding a project.scripts command besides occupying the command name, e.g. gen-classes or create-packages?

@mwtoews
Copy link
Contributor Author

mwtoews commented Aug 10, 2023

There's no big downsides, it just creates several objects (e.g. an .exe wrapper for Windows). These do get cleaned-up with pip uninstall flopy too. My rationale on "why not" is that most users won't need it.

Calling modules in Python is pretty common (e.g. python -m numpy.f2py -h).

@mwtoews
Copy link
Contributor Author

mwtoews commented Aug 10, 2023

Another future consideration is to expose a top-level flopy command with sub-commands. E.g.

$ flopy generate_classes -h

and I say future consideration, since there could be other potential sub-commands. A few ideas:

  • flopy info to get basic information on a model
  • flopy plot to generate plots from a model and/or simulation resullt

And probably others. You can see example sub-commands with git -h to get an idea of what I'm thinking.

@jdhughes-usgs
Copy link
Contributor

@w-bonelli not sure if your recent CI changes impact this PR.

@wpbonelli
Copy link
Member

wpbonelli commented Aug 16, 2023

I think this should not present any CI issues.

The top-level flopy command with subcommands seems nice from a user perspective and it would also disambiguate any potential overlap with non-flopy commands. Maybe before the next minor release that could be implemented for this and get-modflow.

@wpbonelli wpbonelli merged commit e020308 into modflowpy:develop Aug 16, 2023
21 checks passed
@mwtoews mwtoews deleted the cli-generate_classes branch August 16, 2023 19:07
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.

feature: create packages() for MODFLOW 6 as a executable
3 participants