|
1 | | -"""Utilities for building Exorcist task graphs and task databases.""" |
| 1 | +"""Utilities for building Exorcist task graphs and task databases. |
| 2 | +
|
| 3 | +This module translates an :class:`gufe.AlchemicalNetwork` into Exorcist task |
| 4 | +structures and can initialize an Exorcist task database from that graph. |
| 5 | +""" |
2 | 6 |
|
3 | 7 | from pathlib import Path |
4 | 8 |
|
|
12 | 16 | def alchemical_network_to_task_graph( |
13 | 17 | alchemical_network: AlchemicalNetwork, warehouse: WarehouseBaseClass |
14 | 18 | ) -> nx.DiGraph: |
15 | | - """Build a global task DAG from an AlchemicalNetwork.""" |
| 19 | + """Build a global task DAG from an alchemical network. |
| 20 | +
|
| 21 | + Parameters |
| 22 | + ---------- |
| 23 | + alchemical_network : AlchemicalNetwork |
| 24 | + Network containing transformations to execute. |
| 25 | + warehouse : WarehouseBaseClass |
| 26 | + Warehouse used to persist protocol units as tasks while the graph is |
| 27 | + constructed. |
| 28 | +
|
| 29 | + Returns |
| 30 | + ------- |
| 31 | + nx.DiGraph |
| 32 | + A directed acyclic graph where each node is a task ID in the form |
| 33 | + ``"<transformation_key>:<protocol_unit_key>"`` and edges encode |
| 34 | + protocol-unit dependencies. |
| 35 | +
|
| 36 | + Raises |
| 37 | + ------ |
| 38 | + ValueError |
| 39 | + Raised if the assembled task graph is not acyclic. |
| 40 | + """ |
16 | 41 |
|
17 | 42 | global_dag = nx.DiGraph() |
18 | 43 | for transformation in alchemical_network.edges: |
@@ -40,7 +65,27 @@ def build_task_db_from_alchemical_network( |
40 | 65 | db_path: Path | None = None, |
41 | 66 | max_tries: int = 1, |
42 | 67 | ) -> exorcist.TaskStatusDB: |
43 | | - """Create an Exorcist TaskStatusDB from an AlchemicalNetwork.""" |
| 68 | + """Create and populate a task database from an alchemical network. |
| 69 | +
|
| 70 | + Parameters |
| 71 | + ---------- |
| 72 | + alchemical_network : AlchemicalNetwork |
| 73 | + Network containing transformations to convert into task records. |
| 74 | + warehouse : WarehouseBaseClass |
| 75 | + Warehouse used to persist protocol units while building the task DAG. |
| 76 | + db_path : pathlib.Path or None, optional |
| 77 | + Location of the SQLite-backed Exorcist database. If ``None``, defaults |
| 78 | + to ``Path("tasks.db")`` in the current working directory. |
| 79 | + max_tries : int, default=1 |
| 80 | + Maximum number of retries for each task before Exorcist marks it as |
| 81 | + ``TOO_MANY_RETRIES``. |
| 82 | +
|
| 83 | + Returns |
| 84 | + ------- |
| 85 | + exorcist.TaskStatusDB |
| 86 | + Initialized task database populated with graph nodes and dependency |
| 87 | + edges derived from ``alchemical_network``. |
| 88 | + """ |
44 | 89 | if db_path is None: |
45 | 90 | db_path = Path("tasks.db") |
46 | 91 |
|
|
0 commit comments