From 548146e75059c0026c5795ecb57c9d37e05748a0 Mon Sep 17 00:00:00 2001 From: Alekhya Sai Date: Mon, 7 Mar 2022 22:15:10 +0530 Subject: [PATCH] Update pod example for local run (#680) * Update pod example for local run Signed-off-by: Alekhya Sai Punnamaraju * Grammar changes Signed-off-by: Alekhya Sai Punnamaraju * Apply suggestions from code review Co-authored-by: Samhita Alla Co-authored-by: Samhita Alla --- cookbook/integrations/kubernetes/pod/pod.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/cookbook/integrations/kubernetes/pod/pod.py b/cookbook/integrations/kubernetes/pod/pod.py index 24cb132a8b..1e0c4f2b6a 100644 --- a/cookbook/integrations/kubernetes/pod/pod.py +++ b/cookbook/integrations/kubernetes/pod/pod.py @@ -5,7 +5,7 @@ Pod tasks can be used whenever multiple containers need to spin up within a single task. They expose a fully modifiable Kubernetes `pod spec `__ which can be used to customize the task execution runtime. -All we need to do to use pod tasks is: +All we need to do to use pod tasks are: 1. Define a pod spec 2. Specify the name of the primary container @@ -15,8 +15,7 @@ Pod tasks accept arguments that ordinary container tasks usually accept, such as resource specifications, etc. However, these are only applied to the primary container. To customize other containers brought up during the execution, we can define a full-fledged pod spec. -This is done using the `Kubernetes Python client library `__, -specifically with the +This is done using the `Kubernetes Python client library `__'s, `V1PodSpec `__. """ @@ -49,10 +48,10 @@ # We define a simple pod spec with two containers. def generate_pod_spec_for_task(): - # primary containers do not require us to specify an image, the default image built for Flyte tasks will get used + # Primary containers do not require us to specify an image, the default image built for Flyte tasks will get used. primary_container = V1Container(name="primary") - # NOTE: for non-primary containers, we must specify the image + # NOTE: For non-primary containers, we must specify the image. secondary_container = V1Container( name="secondary", image="alpine", @@ -97,7 +96,7 @@ def generate_pod_spec_for_task(): ), ) def my_pod_task() -> str: - # the code defined in this task will get injected into the primary container. + # The code defined in this task will get injected into the primary container. while not os.path.isfile(_SHARED_DATA_PATH): time.sleep(5) @@ -162,6 +161,8 @@ def my_map_workflow(a: List[int]) -> str: return coalesced # %% -# Since pod tasks cannot be run locally, we use the ``pass`` keyword to skip running the tasks. +# The workflows can be executed locally as follows: if __name__ == "__main__": - pass + print(f"Running {__file__} main...") + print(f"Calling PodWorkflow()... {PodWorkflow()}") + print(f"Calling my_map_workflow()... {my_map_workflow()}")