From a52f915f61a45c4dbe6e8aa4669fde69419c2aa9 Mon Sep 17 00:00:00 2001 From: Katrina Rogan Date: Tue, 16 Jun 2020 15:59:04 -0700 Subject: [PATCH 1/4] Single task execution docs --- rsts/user/features/index.rst | 3 +- rsts/user/features/single_task_execution.rst | 90 ++++++++++++++++++++ 2 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 rsts/user/features/single_task_execution.rst diff --git a/rsts/user/features/index.rst b/rsts/user/features/index.rst index 162eba13bf..fa63da0739 100644 --- a/rsts/user/features/index.rst +++ b/rsts/user/features/index.rst @@ -12,5 +12,6 @@ Flyte Features notifications labels_annotations launchplans - task_cache roles + single_task_execution + task_cache diff --git a/rsts/user/features/single_task_execution.rst b/rsts/user/features/single_task_execution.rst new file mode 100644 index 0000000000..68678b44d0 --- /dev/null +++ b/rsts/user/features/single_task_execution.rst @@ -0,0 +1,90 @@ +.. _features-singletaskexec: + +Single Task Excution +#################### + +What are single task executions? +================================ + +Tasks are the most atomic unit of execution in Flyte. Although workflows are traditionally composed of multiple tasks with dependencies +defined by shared inputs and outputs it can be helpful to execute a single task during the process of iterating on its definition. +It can be tedious to write a new workflow definition every time you want to excecute a single task under development but single task +executions can be used to easily iterate on task logic. + +Launch a single task +==================== + +After you've built an image with your updated task code, create an execution using launch: + +.. code-block:: python + + @inputs(plant=Types.String) + @outputs(out=Types.String) + @python_task + def my_task(wf_params, plant, out) + ... + + + my_single_task_execution = my_task.launch(project="my_flyte_projext", domain="development", inputs={'plant': 'ficus'}) + print("Created {}".format(my_task_exec.id)) + +Just like workflow executions, you can optionally pass a user-defined name, labels, annotations, and/or notifications when launching a single task. + +The type of ``my_single_task_execution`` is `SdkWorkflowExecution _` +and has the full set of methods and functionality available for conventional WorkflowExecutions. + + +Fetch and launch a single task +============================== + +Single task executions aren't limited to just tasks you've defined in your code. You can reference previously registered tasks and launch a single task execution like so: + +.. code-block:: python + + from flytekit.common.tasks import task as _task + + my_task = _task.SdkTask.fetch("my_flyte_project", "production", "workflows.my_task", "abc123") # project, domain, name, version + + my_task_exec = my_task.launch(project="my_other_project", domain="development", inputs={'plant': 'philodendron'}) + my_task_exec.wait_for_completion() + + +Launch a single task from the commandline +========================================= + +Previously registered tasks can also be launched from the command-line using :ref:`flyte-cli ` + +.. code-block:: console + + $ flyte-cli -h example.com -p my_flyte_project -d development launch-task \ + -u tsk:my_flyte_project:production:my_complicated_task:abc123 -- an_input=hi \ + other_input=123 more_input=qwerty + + +Monitoring single task executions in the Flyte console +====================================================== + +Single task executions don't have yet have native support in the Flyte console but they're accessible using the same URLs as ordinary workflow executions. + +For example, for a console hosted example.com you can visit example.com/console/projects//domains//executions/ to track the progress of +your execution. Log links and status changes will be available as your execution progresses. + + +Registering and launching a single task +======================================= + +A certain category of tasks don't rely on custom containers with registered images to run. Therefore, you may find it convenient to use +``register_and_launch`` on a task definition to immediately launch a single task execution, like so: + +.. code-block:: python + + containerless_task = SdkPrestoTask( + task_inputs=inputs(ds=Types.String, count=Types.Integer, rg=Types.String), + statement="SELECT * FROM flyte.widgets WHERE ds = '{{ .Inputs.ds}}' LIMIT '{{ .Inputs.count}}'", + output_schema=Types.Schema([("a", Types.String), ("b", Types.Integer)]), + routing_group="{{ .Inputs.rg }}", + ) + + my_single_task_execution = containerless_task.register_and_launch(project="my_flyte_projext", domain="development", + inputs={'ds': '2020-02-29', 'count': 10, 'rg': 'my_routing_group'}) + From 2763800e58f5443f967af767f0fdcd427deeeac4 Mon Sep 17 00:00:00 2001 From: Katrina Rogan Date: Tue, 16 Jun 2020 16:02:55 -0700 Subject: [PATCH 2/4] fixes --- rsts/user/features/single_task_execution.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rsts/user/features/single_task_execution.rst b/rsts/user/features/single_task_execution.rst index 68678b44d0..e419361e63 100644 --- a/rsts/user/features/single_task_execution.rst +++ b/rsts/user/features/single_task_execution.rst @@ -30,7 +30,7 @@ After you've built an image with your updated task code, create an execution usi Just like workflow executions, you can optionally pass a user-defined name, labels, annotations, and/or notifications when launching a single task. -The type of ``my_single_task_execution`` is `SdkWorkflowExecution _` +The type of ``my_single_task_execution`` is `SdkWorkflowExecution `_ and has the full set of methods and functionality available for conventional WorkflowExecutions. @@ -64,9 +64,9 @@ Previously registered tasks can also be launched from the command-line using :re Monitoring single task executions in the Flyte console ====================================================== -Single task executions don't have yet have native support in the Flyte console but they're accessible using the same URLs as ordinary workflow executions. +Single task executions don't yet have native support in the Flyte console but they're accessible using the same URLs as ordinary workflow executions. -For example, for a console hosted example.com you can visit example.com/console/projects//domains//executions/ to track the progress of +For example, for a console hosted example.com you can visit ``example.com/console/projects//domains//executions/`` to track the progress of your execution. Log links and status changes will be available as your execution progresses. From ec89dae71085955b896c1dc36006ed472ca80126 Mon Sep 17 00:00:00 2001 From: Katrina Rogan Date: Tue, 16 Jun 2020 16:05:08 -0700 Subject: [PATCH 3/4] one more --- rsts/user/features/single_task_execution.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rsts/user/features/single_task_execution.rst b/rsts/user/features/single_task_execution.rst index e419361e63..d3d258ec29 100644 --- a/rsts/user/features/single_task_execution.rst +++ b/rsts/user/features/single_task_execution.rst @@ -26,7 +26,7 @@ After you've built an image with your updated task code, create an execution usi my_single_task_execution = my_task.launch(project="my_flyte_projext", domain="development", inputs={'plant': 'ficus'}) - print("Created {}".format(my_task_exec.id)) + print("Created {}".format(my_single_task_execution.id)) Just like workflow executions, you can optionally pass a user-defined name, labels, annotations, and/or notifications when launching a single task. From affb377dc330f8e33f22acefdeaf12f338459cca Mon Sep 17 00:00:00 2001 From: Katrina Rogan Date: Tue, 16 Jun 2020 16:06:09 -0700 Subject: [PATCH 4/4] what is the alphabet anyways --- rsts/user/features/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rsts/user/features/index.rst b/rsts/user/features/index.rst index fa63da0739..2fe64833f5 100644 --- a/rsts/user/features/index.rst +++ b/rsts/user/features/index.rst @@ -12,6 +12,6 @@ Flyte Features notifications labels_annotations launchplans + task_cache roles single_task_execution - task_cache