Skip to content

Commit e793f1e

Browse files
authored
Merge pull request #18 from dwhswenson/fix_docs
Fix docs
2 parents 7471eda + 6fa45a7 commit e793f1e

File tree

4 files changed

+97
-13
lines changed

4 files changed

+97
-13
lines changed

docs/for_core/cli.rst

Lines changed: 89 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ to develop plugins for the CLI, see its documentation. The CLI subcommands
2828
are defined through a plugin system, which makes it very easy for developers
2929
to create new subcommands.
3030

31-
* CLI documentation:
32-
* CLI code repository:
31+
* CLI documentation: https://openpathsampling-cli.readthedocs.io/
32+
* CLI code repository: https://github.com/openpathsampling/openpathsampling-cli/
3333

3434
Workflow with the CLI
3535
---------------------
@@ -41,6 +41,76 @@ files.
4141

4242
To use it, you'll want to first set up
4343

44+
45+
Finding your way around the CLI
46+
-------------------------------
47+
48+
Like many command line tools, the OPS CLI has the options ``-h`` or
49+
``--help`` to get help. If you run ``openpathsampling --help`` you should
50+
see something like this::
51+
52+
Usage: openpathsampling [OPTIONS] COMMAND [ARGS]...
53+
54+
OpenPathSampling is a Python library for path sampling simulations. This
55+
command line tool facilitates common tasks when working with
56+
OpenPathSampling. To use it, use one of the subcommands below. For
57+
example, you can get more information about the pathsampling tool with:
58+
59+
openpathsampling pathsampling --help
60+
61+
Options:
62+
--log PATH logging configuration file
63+
-h, --help Show this message and exit.
64+
65+
Simulation Commands:
66+
visit-all Run MD to generate initial trajectories
67+
equilibrate Run equilibration for path sampling
68+
pathsampling Run any path sampling simulation, including TIS variants
69+
70+
Miscellaneous Commands:
71+
contents list named objects from an OPS .nc file
72+
append add objects from INPUT_FILE to another file
73+
74+
The ``--log`` option takes a logging configuration file (e.g., `logging.conf
75+
<>`_, and sets that logging behavior. If you use it, it must come before the
76+
subcommand name.
77+
78+
You can find out more about each subcommand by putting ``--help`` *after*
79+
the subcommand name, e.g., ``openpathsampling pathsampling --help``, which
80+
returns::
81+
82+
Usage: openpathsampling pathsampling [OPTIONS] INPUT_FILE
83+
84+
General path sampling, using setup in INPUT_FILE
85+
86+
Options:
87+
-o, --output-file PATH output ncfile [required]
88+
-m, --scheme TEXT identifier for the move scheme
89+
-t, --init-conds TEXT identifier for initial conditions (sample set or
90+
trajectory)
91+
-n, --nsteps INTEGER number of Monte Carlo trials to run
92+
-h, --help Show this message and exit.
93+
94+
Here you see the list of the options for the running a path sampling
95+
simulation. In general, path sampling requires an output
96+
file, a move scheme and initial conditions from some input file, and the
97+
number of steps to run. Note that only the output file is technically
98+
required: the CLI will default to running 0 steps (essentially, testing the
99+
validity of your setup), and it can try to guess the move scheme and initial
100+
conditions. In general, the way it guesses follows the following path:
101+
102+
1. If there is only one object of the suitable type in the INPUT_FILE, use
103+
that.
104+
2. If there are multiple objects of the correct type, but only one has a
105+
name, use the named object.
106+
3. In special cases it looks for specific names, such as
107+
``initial_conditions``, and will use those.
108+
109+
Full details on how various CLI parameters search the storage can be seen in
110+
the `Parameter Interpretation
111+
<https://openpathsampling-cli.readthedocs.io/en/latest/interpretation.html>`_
112+
section of the CLI docs.
113+
44114
Simulation Commands
45115
-------------------
46116

@@ -68,9 +138,6 @@ Here are some of the simulation commands implemented in the OPS CLI:
68138
have been visited (works for MSTIS or any 2-state system); must provide
69139
states, engine, and initial snapshot on command line
70140

71-
.. TODO figure showing how these all work -- what is needed for each, what
72-
is implicit
73-
74141
Miscellaneous Commands
75142
----------------------
76143

@@ -81,11 +148,27 @@ the CLI:
81148

82149
* ``contents``: list all the named objects in an OPS storage, organized by
83150
store (type); this is extremely useful to get the name of an object to use
84-
as command-line input to one of the simulation scripts
151+
152+
85153
.. * ``strip-snapshots``: create a copy of the input storage file with the
86154
details (coordinates/velocities) of all snapshots removed; this allows you
87155
to make a much smaller copy (with results of CVs) to copy back to a local
88156
computer for analysis
157+
89158
* ``append`` : add an object from once OPS storage into another one; this is
90159
useful for getting everything into a single file before running a
91160
simulation
161+
162+
Customizing the CLI
163+
-------------------
164+
165+
The OPS CLI uses a flexible plugin system to enable users to easily add
166+
custom functionality. This way, you can create and distribute custom
167+
plugins, giving more functionality to other users who would benefit from it,
168+
without adding everything to the core package and thus overwhelming new
169+
users.
170+
171+
Installing a plugin is easy: just create the directory
172+
``$HOME/.openpathsampling/cli-plugins/``, and copy the plugin Python script
173+
into there. For details on how to write a CLI plugin, see the `CLI
174+
development docs <https://openpathsampling-cli.readthedocs.io/>`_.

docs/full_cli.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ currently gives all commands alphabetically, without regard to section. In
99
general, this is not yet well-organized; contributions to improve that would
1010
be appreciated.
1111

12-
.. click:: paths_cli.cli:OPS_CLI
12+
.. click:: paths_cli.cli:main
1313
:prog: openpathsampling
1414
:show-nested:

docs/sphinx-helpers/make_param_table.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import click
1313

1414
from paths_cli import parameters
15+
from paths_cli import param_core
1516

1617
TableEntry = collections.namedtuple("TableEntry",
1718
"param flags get_args help")
@@ -20,7 +21,7 @@ def is_click_decorator(thing):
2021
return getattr(thing, '__module__', None) == 'click.decorators'
2122

2223
def is_parameter(thing):
23-
return (isinstance(thing, parameters.AbstractLoader)
24+
return (isinstance(thing, param_core.AbstractLoader)
2425
or is_click_decorator(thing))
2526

2627
def rst_wrap(code):
@@ -33,18 +34,18 @@ def flags_help(click_decorator):
3334
return flags, help_
3435

3536
def get_args(parameter):
36-
if isinstance(parameter, parameters.StorageLoader):
37+
if isinstance(parameter, param_core.StorageLoader):
3738
return "``name``"
38-
elif isinstance(parameter, (parameters.OPSStorageLoadNames,
39-
parameters.OPSStorageLoadSingle)):
39+
elif isinstance(parameter, (param_core.OPSStorageLoadNames,
40+
param_core.OPSStorageLoadSingle)):
4041
return "``storage``, ``name``"
4142
elif is_click_decorator(parameter):
4243
return "No ``get`` function"
4344
else:
4445
return "Unknown"
4546

4647
def get_click_decorator(thing):
47-
if isinstance(thing, parameters.AbstractLoader):
48+
if isinstance(thing, param_core.AbstractLoader):
4849
return thing.param.clicked()
4950
elif is_click_decorator(thing):
5051
return thing

paths_cli/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,4 @@ def main(log):
146146
logger.debug("About to run command") # TODO: maybe log invocation?
147147

148148
if __name__ == '__main__': # no-cov
149-
cli()
149+
main()

0 commit comments

Comments
 (0)