diff --git a/docs/source/assets/automation/create-interval-automation-example.png b/docs/source/assets/automation/create-interval-automation-example.png new file mode 100644 index 00000000..616638c2 Binary files /dev/null and b/docs/source/assets/automation/create-interval-automation-example.png differ diff --git a/docs/source/automation/automation-usecase.md b/docs/source/automation/example-data-addition.md similarity index 100% rename from docs/source/automation/automation-usecase.md rename to docs/source/automation/example-data-addition.md diff --git a/docs/source/automation/example-interval.md b/docs/source/automation/example-interval.md new file mode 100644 index 00000000..203e5185 --- /dev/null +++ b/docs/source/automation/example-interval.md @@ -0,0 +1,79 @@ +# Automation Example - Interval Trigger + +Note: This document is a work in progress and is subject to change. + +We will walk through the process of creating an [automation](overview.md) using `Interval` trigger on Latch which will run automation workflow hourly. We assume that you understand how to write and register [Workflows](../basics/what_is_a_workflow.md) on Latch. + +**Terms:** +- _Automation Workflow_: workflow which will be called by automation. This is the workflow we create in [step 1](#1-create-the-automation-workflow) of this tutorial. + +## 1: Create the Automation Workflow +Below is a simple workflow example which creates folder `output` with a file locally and pushes it to Latch Data. + +Note: to upload `LatchDir` or `` + +1. Initialize a new workflow using `latch init automation-wf`. +2. Replace `__init__.py` and `task.py` with the following sample code. + ```python + # __init__.py + + from wf.task import task + + from latch.resources.workflow import workflow + from latch.types.directory import LatchDir, LatchOutputDir + from latch.types.file import LatchFile + from latch.types.metadata import LatchAuthor, LatchMetadata, LatchParameter + + metadata = LatchMetadata( + display_name="Interval Automation Workflow", + author=LatchAuthor( + name="Your Name", + ), + # Note: parameters have to be empty for this workflow to be successfully run by the automation + parameters={}, + ) + + + @workflow(metadata) + def workflow() -> None: + task() + ``` + + ```python + # task.py + + import os + from urllib.parse import urljoin + + from latch import message + from latch.resources.tasks import small_task + from latch.types.directory import LatchDir, LatchFile, LatchOutputDir + + @small_task + def task() -> LatchDir: + os.mkdir("output") + with open("output/hello_world.txt", 'w') as file: + file.write("Hello World!") + + return LatchDir("output", "LDATA PATH FOR THE DIRECTORY") + ``` + +3. Register the sample target workflow with Latch using +```shell-session +$ latch register --remote --yes automation-wf +``` +5. Test the workflow by running it on Latch + +## 2. Create Automation + +Navigate to [Automations](https://console.latch.bio/automations) tab via **Worfklows** > **Automations** and click on the **Create Automation** button. + +1. Input an **Automation Name** and **Description**. + +2. Select the `Event Type` as `Interval`. + +3. Specify `Interval` to 1 hour. + +4. Select the automation workflow that you have just registered with Latch. + +![Create Interval Automation Example](../assets/automation/create-interval-automation-example.png) diff --git a/docs/source/automation/overview.md b/docs/source/automation/overview.md index 955c2fda..0531b9a7 100644 --- a/docs/source/automation/overview.md +++ b/docs/source/automation/overview.md @@ -105,7 +105,7 @@ This is the [workflow](../basics/what_is_a_workflow.md) that will run whenever t In case you need more parameters to pass your workflow, we suggest to hard-code them into your workflow while we are working on adding parameter support for automations. -See an [example](automation-usecase.md) of how we create an automation workflow with `Data Added` trigger which reads all children of the target directory and kicks off another workflow which runs processing on child directories. +See an [example](example-data-addition.md) of how we create an automation workflow with `Data Added` trigger which reads all children of the target directory and kicks off another workflow which runs processing on child directories. ## Creating an Automation @@ -123,7 +123,7 @@ See an [example](automation-usecase.md) of how we create an automation workflow 5. Select the [automation workflow](#automation-workflow) that you have just registered with Latch. -Checkout an [example](automation-usecase.md) on how to create and register automation workflows with `Data Added` triggers. +Checkout an [example](example-data-addition.md) on how to create and register automation workflows with `Data Added` triggers. ![Create Automation Example](../assets/automation/create-automation-example.png) diff --git a/docs/source/index.md b/docs/source/index.md index 84f6c294..40f2895b 100644 --- a/docs/source/index.md +++ b/docs/source/index.md @@ -123,7 +123,8 @@ registry/record.md :maxdepth: 2 :caption: Automation automation/overview.md -automation/automation-usecase.md +automation/example-data-addition.md +automation/example-interval.md ``` ```{toctree}