-
Notifications
You must be signed in to change notification settings - Fork 54
exorcist user-facing docs #2076
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: epic/execution_improvements
Are you sure you want to change the base?
Changes from all commits
f278d4f
1f6ae4d
cc8edd5
34fc236
c188e93
2741ebd
0b55297
17c89d4
cbad6a8
22f278b
66f27cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| .. userguide_exorcist: | ||
|
|
||
| Execution with Exorcist Workers | ||
| =============================== | ||
|
|
||
| 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``: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As a user, it's not immediately clear to me what
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
||
| 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> |
There was a problem hiding this comment.
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...