respec / HSPsquared

Hydrologic Simulation Program Python (HSPsquared)
GNU Affero General Public License v3.0
43 stars 17 forks source link

Added setup.py for pip install which also installs a 'hsp2' command #65

Closed timcera closed 2 years ago

timcera commented 2 years ago

Added a setup.py command which:

The only change made to any conda settings was to add the "mando" library to the "environment*.yml" files. "mando" is used to support the command line environment.

To install from the current local directory using pip: pip install .

To install from the current local directory including the "dev" dependencies: pip install .[dev]

To install an editable version from the current local directory using pip: pip install -e .

And of course if RESPEC published the package to pypi.org (setting up an account and running "python setup.py publish") then to install HSPsquared and all dependencies from any python environment anywhere in the world: pip install HSPsquared

hsp2 Command

The pip installed 'hsp2' command has help created from the function docstrings in HSP2tools/HSP2_CLI.py.

hsp2 --help

usage: hsp2 [-h] {run,import_uci} ...

positional arguments:
  {run,import_uci}
    run             Run a HSPsquared model.
    import_uci      Import UCI and WDM files into HDF5 file.

optional arguments:
  -h, --help        show this help message and exit

And there is a help for each sub-command:

hsp2 import_uci --help

usage: hsp2 import_uci [-h] ucifile h5file

Import UCI and WDM files into HDF5 file.

positional arguments:
  ucifile     The UCI file to import into HDF file.
  h5file      The destination HDF5 file.

optional arguments:
  -h, --help  show this help message and exit

hsp2 run --help

usage: hsp2 run [-h] [--saveall] [--jupyterlab] hdfname

Run a HSPsquared model.

positional arguments:
  hdfname       HDF5 (path) filename used for both input and output.

optional arguments:
  -h, --help    show this help message and exit
  --saveall     [optional] Default is False. Saves all calculated data ignoring SAVE tables.
  --jupyterlab  Jupyterlab

Intended workflow from the command line would be something like:

hsp2 import_uci import_test.uci new_model.h5
# The previous command will import all WDM files listed in the "FILES" block along with the tables in the UCI file.
hsp2 run new_model.h5
aufdenkampe commented 2 years ago

@timcera, thank you for following up on your offer from issue #55!

We'll test this soon and pull it in!

PaulDudaRESPEC commented 2 years ago

Yes, thanks @timcera. Implementing "pip install HSPSquared" would be great for the next release!

rburghol commented 2 years ago

Any ideas on the best way to test this while waiting for the RESPEC folks to finish their review before merging? I am thinking "git clone ..." of timcera:develop, but wanted to ask first in case someone has a better idea.

aufdenkampe commented 2 years ago

@rburghol, thanks for offering to test this Pull Request!

It's awesome that you opened up this issue and shared your results here:

To clear that error, @timcera will need to merge PR https://github.com/timcera/HSPsquared/pull/1 that I just created, which addresses issue #64 that @PaulDudaRESPEC just mentioned.

BTW, I'm continuing the conversation on testing this PR in this PR thread itself, so to keep all the relevant info in one place.

aufdenkampe commented 2 years ago

Pulling this PR into the new setup_pip branch, to enable testing by @rburghol and others in combination with recent commits.

timcera commented 2 years ago

Merged in timcera#1 but now I am confused because it looks like should use respec:setup_pip branch for testing. Am I understanding that correctly?

aufdenkampe commented 2 years ago

@timcera, thanks for merging.

Now that you've done that, you should be able to use either your branch or the new respec:setup_pip for testing. Either will work.

@sjordan29 has availability in the next couple of days, so I wanted to make sure she could test it all together. My apologies for the confusion by creating two paths.

If you make any edits on your end after testing, feel free to issue a new PR.