Skip to content
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

[dag] Fix the workflow doc code build #37249

Merged
merged 5 commits into from
Jul 10, 2023
Merged
Changes from 4 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
25 changes: 13 additions & 12 deletions doc/source/workflows/basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -308,30 +308,31 @@ Idempotent workflow:
Dynamic workflows
-----------------

Workflow tasks can be dynamically created in the runtime. In theory, Ray DAG is
static which means a DAG node can't be returned in a DAG node. For example, the
following code is invalid:
Ray DAGs are static -- returning a node from another node is not a valid way to
construct a graph. For example, the following code will print an instance of a DAG
node, not the output of `bar`:
edoakes marked this conversation as resolved.
Show resolved Hide resolved

.. testcode::

@ray.remote
def bar(): ...
def bar():
print("Hello from bar!")

@ray.remote
def foo():
return bar.bind() # This is invalid since Ray DAG is static
# This will be evaluated at runtime, not in DAG construction.
edoakes marked this conversation as resolved.
Show resolved Hide resolved
return bar.bind()

try:
ray.get(foo.bind().execute()) # This will error
except ray.exceptions.RayTaskError:
print("Ray DAG is static")
# Executing `foo` returns the `bar` DAG node, *not* its result.
print("Output of foo DAG:", type(ray.get(foo.bind().execute())))

.. testoutput::

Ray DAG is static
Output of foo DAG: <class 'ray.dag.function_node.FunctionNode'>


Workflow introduces a utility function called ``workflow.continuation`` which
makes Ray DAG node can return a DAG in the runtime:
To enable dynamically executing DAG nodes at runtime, workflows introduces a utility
function called ``workflow.continuation``:

.. testcode::

Expand Down