From 9c33b9c1f3525bc49de8afcaf7c024c31c0795ce Mon Sep 17 00:00:00 2001 From: nikki everett Date: Tue, 9 Apr 2024 15:45:15 -0500 Subject: [PATCH] first commit Signed-off-by: nikki everett --- .../chaining_flyte_entities.md | 78 ++----------------- 1 file changed, 7 insertions(+), 71 deletions(-) diff --git a/docs/user_guide/advanced_composition/chaining_flyte_entities.md b/docs/user_guide/advanced_composition/chaining_flyte_entities.md index f51b45a2d0..9397c653eb 100644 --- a/docs/user_guide/advanced_composition/chaining_flyte_entities.md +++ b/docs/user_guide/advanced_composition/chaining_flyte_entities.md @@ -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 @@ -31,65 +12,20 @@ This is particularly valuable when chaining tasks and subworkflows without the n ## 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/advanced_composition/chain_entities.py +:lines: 3-32 ``` -+++ {"lines_to_next_cell": 0} - (chain_subworkflow)= ## Subworkflows Just like tasks, you can chain {ref}`subworkflows `. -```{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/advanced_composition/chain_entities.py +:lines: 36-51 ``` To run the provided workflows on the Flyte cluster, use the following commands: