Skip to content

Commit

Permalink
Merge pull request #244 from OpenFreeEnergy/issue223
Browse files Browse the repository at this point in the history
Clarify "DAG dependency order" in docstrings
  • Loading branch information
dwhswenson authored Oct 10, 2023
2 parents dcc7896 + ad6f345 commit 1b7c832
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions gufe/protocols/protocoldag.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ def graph(self) -> nx.DiGraph:

@property
def protocol_units(self) -> list[ProtocolUnit]:
"""List of `ProtocolUnit`s given in DAG-dependency order."""
"""
List of `ProtocolUnit`s given in DAG-dependency order.
DAG-dependency order guarantees that any task is listed after all of its
dependencies.
"""
return list(self._iterate_dag_order(self._graph))

@property
Expand Down Expand Up @@ -154,6 +159,10 @@ def _from_dict(cls, dct: dict):
def result_graph(self) -> nx.DiGraph:
"""
DAG of `ProtocolUnitResult` nodes with edges denoting dependencies.
Each edge is directed from a task towards its dependencies; for example,
an edge between a production run and its equilibration would point
towards the equilibration unit.
"""
return self._result_graph

Expand All @@ -162,7 +171,8 @@ def protocol_unit_results(self) -> list[ProtocolUnitResult]:
"""
`ProtocolUnitResult`s for each `ProtocolUnit` used to compute this object.
Results are given in DAG-dependency order.
Results are given in DAG-dependency order. In this order, tasks are
always listed after their dependencies.
"""
return list(self._iterate_dag_order(self.result_graph))

Expand All @@ -172,7 +182,8 @@ def protocol_unit_failures(self) -> list[ProtocolUnitFailure]:
Note
----
These are returned in DAG order
These are returned in DAG order, with tasks listed after their
dependencies.
"""
# mypy can't figure out the types here, .ok() will ensure a certain type
# https://mypy.readthedocs.io/en/stable/common_issues.html?highlight=cast#complex-type-tests
Expand All @@ -184,7 +195,8 @@ def protocol_unit_successes(self) -> list[ProtocolUnitResult]:
Note
----
These are returned in DAG order
These are returned in DAG order, with tasks listed after their
dependencies.
"""
return [r for r in self.protocol_unit_results if r.ok()]

Expand Down Expand Up @@ -272,7 +284,7 @@ class ProtocolDAG(GufeTokenizable, DAGMixin):
Optional identifier for this `ProtocolDAGResult`.
protocol_units : list[ProtocolUnit]
`ProtocolUnit`s (given in DAG-dependency order) used to compute this
`ProtocolDAGResult`.
`ProtocolDAGResult`. Tasks are always listed after their dependencies.
graph : nx.DiGraph
Graph of `ProtocolUnit`s as nodes, with directed edges to each
`ProtocolUnit`'s dependencies.
Expand Down

0 comments on commit 1b7c832

Please sign in to comment.