Open ns-rse opened 1 year ago
Documenting possible structure/options
Command | Option(s) | Description |
---|---|---|
config |
--copy |
Make a straight copy of topostats/default_config.yaml , this will include the field descriptors and satisfy #536 |
--create |
Loads topostats/default_config.yaml and updates any options with those specified on the command line, e.g. --output ~/somewhere/else would updated the output value. This would lose the field descriptors requested in #253 |
|
--plotting-dictionary |
Generate a sample plotting dictionary from topostats/plotting_dictionary.yaml . |
|
--file |
File to write output to (default would be sample_config.yaml for default_config.yaml variants or plotting_config.yaml if --plotting-dictionary is requested. |
|
process |
<config_options> |
Run topostats modifying the topostats/default_config.yaml with any specified command line options. |
filter |
<config_options> |
Run just the filtering stage of processing. |
grains |
<config_options> |
Run grain detection on filtered NumPy arrays. |
grain_stats |
<config_options> |
Run grain statsitics calculations on grain detected NumPy arrays. |
dnatracing |
<config_options> |
Run tracing on detected grains. |
curvature |
<config_options> |
Calculate curvature from traced NumPy arrays. |
summarise |
<config_options> |
Run summary plot generation along with specific options. |
Remember to ensure basename
is derived for grainstats_df
as well as tracing_stats_df
.
I think it would be useful to revise the Command Line Interface (CLI) entry point to TopoStats. Currently there are two
run_topostats
andtoposum
but in order to make this extensible I feel we should adopt what is termed the "Swiss Army knife" approach to Command Line Interfaces.This is what programmes such as
git
,pre-commit
and many others use. They have a single command for invocation followed by a sub-command. Usingpre-commit
as an example (as its written in Python and provides a good pattern to emulate)...The main
pre-commit
command has the following help...That is the
positional arguments
are sub-commands, if you want torun
then you have the following options to that...I envisage replacing existing commands with the following (see also table below for further thoughts/details)...
run_topostats
topostats process
toposum
topostats summarise
run_topostats --create-config-file
topostats config
Implementation
Following the example of
pre-commit
this would entail introducing atopostats/main.py
module to provide an entry point oftopostats.main:main
.topostats/main.py
then imports the various commands from a multitude of sub-modules undertopostats/commands/*.py
(there is one for each command).Each arguments are defined for each sub-command within
main.py
in what may be an Abstract Factory design pattern (not quite sure on this front yet!).Additional Changes
In addition all documentation (
README.md
,docs/usage.md
etc.) would also require updating to reflect these changes.Modules to Add
The ground work for this has been set thanks to @SylviaWhittle work in #540. We now need to further modularise the CLI with individual steps corresponding to each class as these are the way in which we delineate the processing steps in the code to run the following processing, each step saving the results for subsequent steps to be used courtesy of #613 which introduced
io.save_topostats_file()
to save the current state to ahdf5
file.