CLI outline / preprocess command
Wildcat Overview
Wildcat is a tool to assess and map post-fire debris-flow hazard assessments. The tool will consist of 5 commands:
- init: Creates a folder and config file for a project
- preprocess: Cleans input files in preparation for assessment
- assess: Computes a hazard assessment
- map: Plots hazard assessment results in a variety of mapping formats
- run: Runs the preprocess, assess, and map commands in sequence
Most users will only need the "run" command. The most basic workflow is to place a variety of input datasets in a folder, then call wildcat run
on the folder. This will produce a "maps" subfolder, containing the hazard assessment maps.
I think it's important that wildcat runs both from the command line:
$ wildcat run my-fire
and within the Python interpreter:
from wildcat import run
run("my-fire")
Project structure
The "wildcat" subfolder holds the source code. The 5 subcommands are each implemented in their own module at the root of this folder. This folder also contains a "cli" subfolder, which implements the command line interface. The CLI is implemented using argparse, and the basic flow is as follows:
- main.py provides the entry point, it initializes a global parser
- A subparser is added for each of the 5 commands. Each subparser has its own module in the "parsers" subfolder
- When a command is called, the parsed args are passed to a hook for the command
- The hook converts the CLI args to a keyword dict (kwargs)
- Imports the command's module
- Then calls the command
CLI options
It the simplest setup, a user can just call a wildcat command from a folder. This will search the current folder using default filenames for the various input datasets. Any output will be placed in a default named subfolder. Alternatively, a user can specify explicit input/output folders as the first/second positional inputs. The user can also specify explicit filenames using CLI options. Most numerical parameters can also be changed using CLI options. The default options are selected to conform to standard USGS assessment parameters.
Notes for Reviewer
This first merge request outlines the project and provides the "preprocess" command. (It also has a sketch of the "init" command). I'm particularly interested in feedback on the project layout/CLI components.
Wildcat is part of a co-release with pfdf. The new part of pfdf is under review, so wildcat won't install correctly from pyproject.toml just yet. This will be corrected in the next merge request, following the completion of the pfdf review. If you would like to install wildcat now, let me know and I can point you to the correct dev branch on pfdf.
The pipeline is currently broken, and that's fine. That will be sorted out in the next merge request, again following the pfdf review.