From d0ed6c47e62736cdaa95795e8384b7841c4c11b0 Mon Sep 17 00:00:00 2001 From: pryce-turner <31577879+pryce-turner@users.noreply.github.com> Date: Mon, 15 Apr 2024 13:59:14 -0700 Subject: [PATCH] Added section on overriding lp config in loop (#5223) * Added section on overriding lp config in loop Signed-off-by: pryce-turner * 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> --------- Signed-off-by: pryce-turner Signed-off-by: pryce-turner <31577879+pryce-turner@users.noreply.github.com> Co-authored-by: Nikki Everett --- .../nested_parallelization.md | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/user_guide/advanced_composition/nested_parallelization.md b/docs/user_guide/advanced_composition/nested_parallelization.md index 73fd921b2e..bc49c70462 100644 --- a/docs/user_guide/advanced_composition/nested_parallelization.md +++ b/docs/user_guide/advanced_composition/nested_parallelization.md @@ -82,6 +82,27 @@ 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 launch plan 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 increment(num=num) + +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