From edaeb20f845b1c10fa4c4ca4e880560fcf2206d0 Mon Sep 17 00:00:00 2001 From: pryce-turner Date: Thu, 11 Apr 2024 08:47:10 -0700 Subject: [PATCH 1/3] Added section on overriding lp config in loop Signed-off-by: pryce-turner --- .../nested_parallelization.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/user_guide/advanced_composition/nested_parallelization.md b/docs/user_guide/advanced_composition/nested_parallelization.md index 73fd921b2e..c1863d3c06 100644 --- a/docs/user_guide/advanced_composition/nested_parallelization.md +++ b/docs/user_guide/advanced_composition/nested_parallelization.md @@ -82,6 +82,23 @@ def multi_wf(l: typing.List[int], chunk: int) -> typing.List[int]: return level1(l=l, chunk=chunk) ``` +Overrides let you add additional arguments to the launchplan you are looping over in the dynamic. Here we add caching: + +```python +@workflow +def child(num: int) -> int: + return num + 1 + +child_lp = LaunchPlan.get_or_create(child) + +@dynamic +def spawn(n: int) -> List[int]: + l = [] + for i in [1,2,3,4,5]: + l.append(child_lp(num=i).with_overrides(cache=True, cache_version="1.0.0")) + # you can also pass l to another task if you want + return l +``` ### Flyte console From 2f942b6e8bc19fcebcc2d8d080b287b129c84792 Mon Sep 17 00:00:00 2001 From: pryce-turner <31577879+pryce-turner@users.noreply.github.com> Date: Thu, 11 Apr 2024 13:46:50 -0700 Subject: [PATCH 2/3] Update docs/user_guide/advanced_composition/nested_parallelization.md Co-authored-by: Nikki Everett Signed-off-by: pryce-turner <31577879+pryce-turner@users.noreply.github.com> --- docs/user_guide/advanced_composition/nested_parallelization.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user_guide/advanced_composition/nested_parallelization.md b/docs/user_guide/advanced_composition/nested_parallelization.md index c1863d3c06..fb44244d5a 100644 --- a/docs/user_guide/advanced_composition/nested_parallelization.md +++ b/docs/user_guide/advanced_composition/nested_parallelization.md @@ -82,7 +82,7 @@ def multi_wf(l: typing.List[int], chunk: int) -> typing.List[int]: return level1(l=l, chunk=chunk) ``` -Overrides let you add additional arguments to the launchplan you are looping over in the dynamic. Here we add caching: +Overrides let you add additional arguments to the launch plan you are looping over in the dynamic. Here we add caching: ```python @workflow From cbed02122627bd64a653c0614c24192942cf858d Mon Sep 17 00:00:00 2001 From: pryce-turner Date: Mon, 15 Apr 2024 13:07:01 -0700 Subject: [PATCH 3/3] Fixed workflow to call a task as workflows cannot increment natively Signed-off-by: pryce-turner --- .../advanced_composition/nested_parallelization.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/user_guide/advanced_composition/nested_parallelization.md b/docs/user_guide/advanced_composition/nested_parallelization.md index c1863d3c06..806b4ebb31 100644 --- a/docs/user_guide/advanced_composition/nested_parallelization.md +++ b/docs/user_guide/advanced_composition/nested_parallelization.md @@ -85,9 +85,13 @@ def multi_wf(l: typing.List[int], chunk: int) -> typing.List[int]: Overrides let you add additional arguments to the launchplan you are looping over in the dynamic. Here we add caching: ```python +@task +def increment(num: int) -> int: + return num + 1 + @workflow def child(num: int) -> int: - return num + 1 + return increment(num=num) child_lp = LaunchPlan.get_or_create(child)