Skip to content

Commit

Permalink
document difference between flow.iterflow() and flow.__iter__()
Browse files Browse the repository at this point in the history
  • Loading branch information
janosh committed Aug 11, 2023
1 parent 94fdb64 commit 781d3b5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 10 additions & 0 deletions docs/tutorials/8-fireworks.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ flow.update_config({"manager_config": {"_fworker": "fworker1"}}, name_filter="jo
flow.update_config({"manager_config": {"_fworker": "fworker2"}}, name_filter="job2")
```

NB: There are two ways to iterate over a `Flow`. The `iterflow` method iterates through a flow such that root nodes of the graph are always returned first. This has the benefit that the `job.output` references can always be resolved.
`Flow` also has an `__iter__` method, meaning you can write

```py
for job_or_subflow in flow:
...
```

to simply iterate through the `Flow.jobs` array. Note that `jobs` can also contain other flows.

### Launching the Jobs

As described above, convert the flow to a workflow via {obj}`flow_to_workflow` and add it to your launch pad.
Expand Down
6 changes: 5 additions & 1 deletion tests/core/test_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,11 @@ def test_dag_validation():
job2 = Job(add, function_args=(job1.output, 2))
job1.function_args = (job2.output, 2)
flow = Flow(jobs=[job1, job2])
with pytest.raises(ValueError):
with pytest.raises(
ValueError,
match="Job connectivity contains cycles therefore job execution order "
"cannot be determined",
):
next(flow.iterflow())


Expand Down

0 comments on commit 781d3b5

Please sign in to comment.