Skip to content

Commit d8e36e3

Browse files
authored
Merge pull request #3 from dwhswenson/docs
Docs, READMEs, etc.
2 parents 93a8c36 + 8c9b027 commit d8e36e3

File tree

17 files changed

+706
-0
lines changed

17 files changed

+706
-0
lines changed

.coveragerc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[report]
2+
omit =
3+
*/python?.?/*
4+
*/openpathsampling/*
5+
*/paths_cli/version.py
6+
*/paths_cli/_installed_version.py
7+
*/paths_cli/tests/*
8+
exclude_lines =
9+
no-cov
10+
def __repr__
11+
raise NotImplementedError

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*.nc
22
_installed_version.py
3+
*.swp
34

45
# Byte-compiled / optimized / DLL files
56
__pycache__/

README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# OpenPathSampling CLI
2+
3+
*The command line interface to OpenPathSampling*
4+
5+
OpenPathSampling is a powerful and flexible library for path sampling
6+
simulations. However, many users would prefer to interact with an executable on
7+
the command line, instead of writing everything in their own Python script.
8+
Here is that command line tool, including some useful scripts for dealing with
9+
OPS output files.
10+
11+
The CLI is used as a single executable, `openpathsampling`, with multiple
12+
subcommands. We recommend aliasing `openpathsampling` to something simpler (maybe `ops`?) to save typing!
13+
14+
Current categories of subcommands are for simulation running, and for
15+
miscellaneous operations on OPS output files.
16+
17+
**Simulation Commands:**
18+
19+
* `visit-all`: Run MD to generate initial trajectories
20+
* `equilibrate`: Run equilibration for path sampling
21+
* `pathsampling`: Run any path sampling simulation, including TIS variants
22+
23+
**Miscellaneous Commands:**
24+
25+
* `contents`: List named objects from an OPS .nc file
26+
* `strip-snapshots`: Remove coordinates/velocities from an OPS storage
27+
* `append`: add objects from INPUT_FILE to another file
28+
29+
Full documentation is at ???; a brief summary is below.
30+
31+
32+
<!-- TODO: add TOC if the contents here get too long
33+
Contents:
34+
35+
* Installation
36+
* Workflow
37+
* Creating your own commands
38+
-->
39+
40+
## Installation
41+
42+
The OPS CLI can be installed with either ``conda`` or ``pip``:
43+
44+
```bash
45+
conda -c conda-forge install openpathsampling-cli
46+
# or
47+
pip install openpathsampling-cli
48+
```
49+
50+
Note that installing the CLI will also install OpenPathSampling, if you don't
51+
already have it.
52+
53+
## Workflow
54+
55+
**Set up, *then* simulate!** The overall idea is that you will first set up your
56+
simulation, and then use these scripts to run the resulting simulation setup
57+
files. Currently, writing a Python script (or better, using a Jupyter notebook
58+
to set things up interactively) is the best way to do that. Save the necessary
59+
simulation objects to a `setup.nc` file, and then use these scripts to run the
60+
simulation.
61+
62+
## Creating your own commands
63+
64+
Creating your own commands is extremely easy. The OPS CLI uses a plug-in
65+
architecture so that installing your own commands is as easy as putting a
66+
Python file in your `~/.openpathsampling/cli-plugins/` directory.
67+
We provide a standard set of parameters as decorators, which can (and should)
68+
be re-used to load things from storage. The CLI is built on
69+
[`click`](https://click.palletsprojects.com/), so additional arguments are
70+
easily added using functionality from `click`. See our developer documentation
71+
for details.

docs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
parameter_table.rst

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/conf.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# This file only contains a selection of the most common options. For a full
4+
# list see the documentation:
5+
# http://www.sphinx-doc.org/en/master/config
6+
7+
# -- Path setup --------------------------------------------------------------
8+
9+
# If extensions (or modules to document with autodoc) are in another directory,
10+
# add these directories to sys.path here. If the directory is relative to the
11+
# documentation root, use os.path.abspath to make it absolute, like shown here.
12+
#
13+
import os
14+
import sys
15+
sys.path.insert(0, os.path.abspath('./sphinx-helpers'))
16+
17+
# -- Preprocessing -----------------------------------------------------------
18+
19+
from make_param_table import main as make_param_main
20+
with open("parameter_table.rst", mode='w') as f:
21+
make_param_main(f)
22+
23+
# -- Project information -----------------------------------------------------
24+
25+
project = 'OpenPathSampling CLI'
26+
copyright = '2019-2020, David W.H. Swenson'
27+
author = 'David W.H. Swenson'
28+
29+
# The full version, including alpha/beta/rc tags
30+
# TODO: get this from the release like other projects do
31+
release = '0.0.1'
32+
33+
34+
# -- General configuration ---------------------------------------------------
35+
36+
# Add any Sphinx extension module names here, as strings. They can be
37+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
38+
# ones.
39+
extensions = [
40+
'sphinx_click.ext',
41+
]
42+
43+
# Add any paths that contain templates here, relative to this directory.
44+
templates_path = ['_templates']
45+
46+
# List of patterns, relative to source directory, that match files and
47+
# directories to ignore when looking for source files.
48+
# This pattern also affects html_static_path and html_extra_path.
49+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
50+
51+
52+
# -- Options for HTML output -------------------------------------------------
53+
54+
# The theme to use for HTML and HTML Help pages. See the documentation for
55+
# a list of builtin themes.
56+
#
57+
html_theme = 'alabaster'
58+
59+
# Add any paths that contain custom static files (such as style sheets) here,
60+
# relative to this directory. They are copied after the builtin static files,
61+
# so a file named "default.css" will overwrite the builtin "default.css".
62+
html_static_path = ['_static']

docs/for_core/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is stuff that really should go into the OPS core docs.

docs/for_core/cli.rst

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
.. _cli:
2+
3+
Command Line Interface
4+
======================
5+
6+
A separate command line tool for OpenPathSamplng can be installed. It is
7+
available via either ``conda`` (channel ``conda-forge``) or ``pip``, with
8+
the package name ``openpathsampling-cli``.
9+
10+
Once you install this, you'll have access to the command
11+
``openpathsampling`` in your shell (although we recommend aliasing that to
12+
either ``paths`` or ``ops`` -- save yourself some typing!)
13+
14+
This command is a gateway to many subcommands, just like ``conda`` and
15+
``pip`` (which have subcommands such as ``install``) or ``git`` (which has
16+
subcommands such as ``clone`` or ``commit``). You can get a full listing all
17+
the subcommands with ``openpathsampling --help``. For more information on
18+
any given subcommand, use ``openpathsampling SUBCOMMAND --help``, replacing
19+
``SUBCOMMAND`` with the subcommand you're interested in.
20+
21+
Here, we will provide a description of a few of the subcommands that the CLI
22+
tool provides. This documentation may not be fully up-to-date with the more
23+
recent releases of the CLI, so use the CLI help tools to get a fuller
24+
understanding of what is included.
25+
26+
For more details on how the CLI interprets its arguments, and to learn how
27+
to develop plugins for the CLI, see its documentation. The CLI subcommands
28+
are defined through a plugin system, which makes it very easy for developers
29+
to create new subcommands.
30+
31+
* CLI documentation:
32+
* CLI code repository:
33+
34+
Workflow with the CLI
35+
---------------------
36+
37+
As always, the process of running a simulation is (1) set up the simulation;
38+
(2) run the simulation; (3) analyze the simulation. The CLI is mainly
39+
focused on step 2, although it also has tools that generally help with OPS
40+
files.
41+
42+
To use it, you'll want to first set up
43+
44+
Simulation Commands
45+
-------------------
46+
47+
One of the main concepts when working with the CLI is that you can create
48+
all the OPS simulation objects without running the simulation, save them in
49+
an OPS storage file, and then load them again to actually run your
50+
simulation. For simulation commands, the options all deal with loading
51+
simulation objects from storage.
52+
53+
The simulation commands include ``equilibration``, ``pathsampling``, and
54+
``simulation``. These commands aren'y necessarily mutually exclusive: you
55+
can accomplish an equilibration phase with any of them. The ``simulation``
56+
command is the most general; if you've any :class:`.PathSimulator` object,
57+
???
58+
59+
Here are some of the simulation commands implemented in the OPS CLI:
60+
61+
* ``pathsampling``: run path sampling with a given move scheme (suitable for
62+
custom TPS schemes as well as TIS/RETIS); must provide move scheme,
63+
iniital conditions, and number of MC steps on command line
64+
* ``simulation``: run arbitrary OPS simulator (including committor and
65+
related); must provide a simulator object and number of steps on the
66+
command line
67+
* ``visit-all``: create initial trajectories by running MD until all states
68+
have been visited (works for MSTIS or any 2-state system); must provide
69+
states, engine, and initial snapshot on command line
70+
71+
.. TODO figure showing how these all work -- what is needed for each, what
72+
is implicit
73+
74+
Miscellaneous Commands
75+
----------------------
76+
77+
Even for users who prefer to develop their OPS projects entirely in Python,
78+
foregoing the CLI tools to run simulations, some of the "miscellaneous"
79+
commands are likely to be quite useful. Here are some that are available in
80+
the CLI:
81+
82+
* ``nclist``: list all the named objects in an OPS storage, organized by
83+
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
85+
* ``strip-snapshots``: create a copy of the input storage file with the
86+
details (coordinates/velocities) of all snapshots removed; this allows you
87+
to make a much smaller copy (with results of CVs) to copy back to a local
88+
computer for analysis

docs/full_cli.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.. _full_cli:
2+
3+
Full CLI
4+
========
5+
6+
This is a full description of the commands available in the CLI,
7+
automatically generated from the help for each command. Note that this
8+
currently gives all commands alphabetically, without regard to section. In
9+
general, this is not yet well-organized; contributions to improve that would
10+
be appreciated.
11+
12+
.. click:: paths_cli.cli:OPS_CLI
13+
:prog: openpathsampling
14+
:show-nested:

docs/index.rst

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
.. OpenPathSampling CLI documentation master file, created by
2+
sphinx-quickstart on Sun Dec 8 01:32:00 2019.
3+
You can adapt this file completely to your liking, but it should at least
4+
contain the root `toctree` directive.
5+
6+
OpenPathSampling CLI
7+
====================
8+
9+
This is documentation for the OpenPathSampling CLI. Most of this is intended
10+
for developers. Basic usage documentation is the in the main OPS docs,
11+
although a few things here might be relevant to users (e.g., the details
12+
of how the built-in parameters interpret user-provided arguments, discussed
13+
in :ref:`interpretation`, or the :ref:`full listing for CLI commands and
14+
arguments <full_cli>`).
15+
16+
The main purpose of this documentation is for people who want to create
17+
their own plugins for the OpenPathsampling CLI. Note that, because the OPS
18+
CLI uses a flexible dynamic plugin structure, installing a plugin is as easy
19+
as adding the plugin file to ``~/.openpathsampling/cli-plugins/``. See also
20+
:ref:`plugins`.
21+
22+
Developing for the OPS CLI is pretty easy. The mains ideas are:
23+
24+
* **Most of the business logic is elsewhere.** There shouldn't be anything
25+
in this repository that involved putting together new move types or
26+
anything like that. All of that belongs in external repositories (such as
27+
OPS itself). All functionality in the CLI should be available in a
28+
library; the CLI is a thin wrapper over the library.
29+
* **Reuse existing parameters whenever possible.** This ensures that
30+
option labels and help strings are constant across the suite of
31+
tools. It also ensures that behavior remains consistent: for example, the
32+
steps that we go through in searching for an initial trajectory is the
33+
same regardless of the type of simulation.
34+
35+
36+
A note on testing:
37+
38+
Because the CLI is a thin wrapper over the library, we can also be
39+
relatively lax in testing. We thoroughly test the OPS loading parameters.
40+
But the actual commands are just chaining together existing well-tested OPS
41+
functions, and so we just do smoke tests for the commands.
42+
43+
Essentially, the testing purpose that these serve would be as system tests
44+
for OPS, and OPS already has system tests. So we smoke test to make sure the
45+
code is sane. Again, this is only acceptable because the commands are thin
46+
wrappers around well-tested OPS code.
47+
48+
.. note::
49+
50+
The project is called OpenPathSampling CLI, and the packages (PyPI and
51+
conda-forge) are called ``openpathsampling-cli``. However, the name you
52+
use to import the package is ``paths_cli``, as a nod to the encouraged
53+
habit of importing openpathsampling as ``paths``.
54+
55+
.. toctree::
56+
:maxdepth: 2
57+
:caption: Contents:
58+
59+
interpretation
60+
plugins
61+
parameters
62+
workflows
63+
full_cli
64+

0 commit comments

Comments
 (0)