Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ dependencies:
- git+https://github.com/OpenFreeEnergy/kartograf@main
- git+https://github.com/OpenFreeEnergy/konnektor@main
- git+https://github.com/OpenFreeEnergy/lomap@main
- git+https://github.com/OpenFreeEnergy/exorcist@main

# These are added automatically by RTD, so we include them here
# for a consistent environment.
Expand Down
105 changes: 105 additions & 0 deletions docs/guide/execution/exorcist_execution.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
.. userguide_exorcist:

Execution with Exorcist Workers

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is missing user centric information on the why of Exorcist. I.e. what is the advantage of using this over the old quickrun, etc...

===============================

Using the API to execute an Alchemical Network
----------------------------------------------

You can execute the network of simulation units defined by an ``AlchemicalNetwork`` (see `create_alchemical_network`) using ``openfe.orchestration``:


First, we build a graph of tasks to be executed from the ``AlchemicalNetwork``:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be good to define tasks here - is that each individual unit that needs to be executed?


.. code:: python

from openfe.orchestration import build_task_db_from_alchemical_network
from openfe.storage import warehouse

alchemical_network = openfe.AlchemicalNetwork.from_json("alchemicalNetwork.json")

# create a Warehouse to define where simulation data is stored
my_warehouse = FileSystemWarehouse()

# store the AlchemicalNetwork in the Warehouse
my_warehouse.store_setup_tokenizable(alchemical_network)

# build a database of tasks from the AlchemicalNetwork
db_path = Path(my_warehouse.root_dir) / "tasks.db"
task_db = build_task_db_from_alchemical_network(alchemical_network, my_warehouse, db_path)


Next, we call ``worker.execute_unit()`` to execute the next available task in the warehouse:

.. code:: python

# execution: build the worker
from openfe.orchestration import Worker

worker = Worker(warehouse=my_warehouse, task_db_path=db_path)

execution = worker.execute_unit(scratch=pathlib.Path("path/to/local/scratch"))


Each time ``worker.execute_unit`` is called, the worker will pick up the next valid task in the AlchemicalNetwork's task graph.


Using the CLI
-------------

.. Note: this is a proof-of-concept for use with RBFEs, tbd if we want to expose this right now.

.. code:: bash

openfe plan-rbfe-network ... --warehouse

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a user, it's not immediately clear to me what --warehouse would do, would I not want to call plan-rbfe-network to get the AlchemicalNetwork and then use that as the input to my execution?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I.e. this section needs a "what arre we doing in each of these calls" explanation.



.. code:: bash

openfe worker warehouse/

To run a single task to completion.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if it doesn't complete? What should users be doing in that instance?

To take full advantage of the worker model, you can run multiple ``openfe worker`` commands concurrently.

The following is an example script that runs up to 4 workers at a time, with each automatically picking up the next valid unit to be executed.

.. code:: bash

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it might be worth adapting this to Python because it is not pleasant to read (even though it is my code lol)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that makes sense given our target audience!


#!/usr/bin/env bash
set -euo pipefail

# Command + args as an array (so spaces are handled correctly)
CMD=(openfe worker warehouse)

MAX_JOBS=4
pids=()

cleanup() {
echo "Stopping workers..."
for pid in "${pids[@]:-}"; do
kill "$pid" 2>/dev/null || true
done
wait 2>/dev/null || true
exit 0
}
trap cleanup INT TERM

run_job() {
while true; do
"${CMD[@]}"
done
}

# Start initial workers
for ((i=0; i<MAX_JOBS; i++)); do
run_job &
pids+=("$!")
done

# Keep 4 running; if one exits, start another
while true; do
wait -n
run_job &
pids+=("$!")
done

8 changes: 6 additions & 2 deletions docs/guide/execution/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@

Execution
=========
The planning and preparation of a campaign of alchemical simulations using ``openfe`` is intended to be achievable on a local workstation in a matter of minutes.

The *execution* of these simulations however requires a large amount of computational power, and beyond running single calculations locally, is intended to be distributed across a HPC environment.

The simplest way to run a Transformation is to use the :ref:`quickrun CLI tool <userguide_quickrun>`.

With a :class:`.Transformation` defined, the next step is to execute this.
The easiest way to run it is to use the :ref:`quickrun CLI tool <userguide_quickrun>`.
More advanced options are available through first considering the
:ref:`theory of the execution model<userguide_execution_theory>`
then :ref:`reading on the available Python functions<reference_execution>`.

.. toctree::
quickrun_execution
exorcist_execution
execution_theory
7 changes: 4 additions & 3 deletions docs/guide/execution/quickrun_execution.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
Execution with Quickrun
=======================

The planning and preparation of a campaign of alchemical simulations using ``openfe`` is intended to be achievable on a local workstation in a matter of minutes.
The *execution* of these simulations however requires a large amount of computational power, and beyond running single calculations locally, is intended to be distributed across a HPC environment.
Doing this requires storing and sending the details of the simulation from the local workstation to a HPC environment, which can be done via the :func:`.Transformation.to_json` function which :ref:`creates a saved JSON version of the data<dumping_transformations>`.
``openfe quickrun`` is the simplest way to execute simulations on a per-Transformation basis.

The :func:`.Transformation.to_json` function :ref:`creates a saved JSON version of the data<dumping_transformations>`.

These serialized JSON files are the currency of executing a campaign of simulations and contain all the information required to execute a single simulation.

To read the ``Transformation`` information and execute the simulation, the command line interface provides the ``openfe quickrun`` command, the full details of which are given in :ref:`the CLI reference section<cli_quickrun>`.
Expand Down
2 changes: 2 additions & 0 deletions docs/reference/api/defining_and_executing_simulations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ Executing Simulations

.. autosummary::
:nosignatures:
:recursive:
:toctree: generated/

execute_DAG
storage

General classes
---------------
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ dependencies:
- git+https://github.com/OpenFreeEnergy/kartograf@main # needs gufe which pins to pydantic < 2.13. update this once gufe v1.13 is released on conda-forge
- git+https://github.com/OpenFreeEnergy/konnektor@main
- git+https://github.com/OpenFreeEnergy/gufe@main
- git+https://github.com/OpenFreeEnergy/exorcist@main
- run_constrained:
# drop this pin when handled upstream in espaloma-feedstock
- smirnoff99frosst>=1.1.0.1 #https://github.com/openforcefield/smirnoff99Frosst/issues/109
23 changes: 23 additions & 0 deletions news/warehouse.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* Added ``openfe.storage.warehouse``, which includes ``WarehouseBaseClass`` and the example implementation ``FileSystemWarehouse``.

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* Removed the unused methods ``metadatastore``, ``resultclient``, and ``resultserver`` from ``openfe.storage``.

**Fixed:**

* <news item>

**Security:**

* <news item>
Loading
Loading