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

[WAIT TO MERGE] Use remoteliteralinclude for code in user guide docs #5207

Merged
merged 18 commits into from
Apr 19, 2024
84 changes: 13 additions & 71 deletions docs/user_guide/advanced_composition/chaining_flyte_entities.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
---
jupytext:
cell_metadata_filter: all
formats: md:myst
main_language: python
notebook_metadata_filter: all
text_representation:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.16.1
kernelspec:
display_name: Python 3
language: python
name: python3
---

+++ {"lines_to_next_cell": 0}

(chain_flyte_entities)=

# Chaining Flyte entities
Expand All @@ -28,68 +9,27 @@ kernelspec:
Flytekit offers a mechanism for chaining Flyte entities using the `>>` operator.
This is particularly valuable when chaining tasks and subworkflows without the need for data flow between the entities.

```{note}
To clone and run the example code on this page, see the [Flytesnacks repo][flytesnacks].
```

## Tasks

Let's establish a sequence where `t1()` occurs after `t0()`, and `t2()` follows `t1()`.

```{code-cell}
from flytekit import task, workflow


@task
def t2():
print("Running t2")
return


@task
def t1():
print("Running t1")
return


@task
def t0():
print("Running t0")
return


@workflow
def chain_tasks_wf():
t2_promise = t2()
t1_promise = t1()
t0_promise = t0()

t0_promise >> t1_promise
t1_promise >> t2_promise

```{rli} https://raw.githubusercontent.com/flyteorg/flytesnacks/master/examples/advanced_composition/advanced_composition/chain_entities.py
:caption: advanced_composition/chain_entities.py
:lines: 1-30
```

+++ {"lines_to_next_cell": 0}

(chain_subworkflow)=
## Subworkflows

Just like tasks, you can chain {ref}`subworkflows <subworkflow>`.

```{code-cell}
:lines_to_next_cell: 2

@workflow
def sub_workflow_1():
t1()


@workflow
def sub_workflow_0():
t0()


@workflow
def chain_workflows_wf():
sub_wf1 = sub_workflow_1()
sub_wf0 = sub_workflow_0()

sub_wf0 >> sub_wf1
```{rli} https://raw.githubusercontent.com/flyteorg/flytesnacks/master/examples/advanced_composition/advanced_composition/chain_entities.py
:caption: advanced_composition/chain_entities.py
:lines: 34-49
```

To run the provided workflows on the Flyte cluster, use the following commands:
Expand All @@ -110,3 +50,5 @@ pyflyte run --remote \
Chaining tasks and subworkflows is not supported in local environments.
Follow the progress of this issue [here](https://github.com/flyteorg/flyte/issues/4080).
:::

[flytesnacks]: https://github.com/flyteorg/flytesnacks/tree/master/examples/advanced_composition/
Loading
Loading