Run your first workflow
In this tutorial you write a workflow that runs the task definition from the previous tutorial, start a run of it, and read what the task printed.
What you will accomplish
By the end of this tutorial you will have:
- A workflow named
Echo workflowin your project - A run of it that ended Complete
- The task's log, showing the message the workflow gave it
Before you begin
- You have completed Create your first project, so you have the project
my-first-project, and Create a task definition, so your account has[email protected]. - Your account's billing status is Active. A run is billed for the compute its task holds and for its shared workspace; see How billing works.
Steps
1. Write the workflow file
Create a file called my-workflow.yaml with the following content:
name: Echo workflow
compute_type: cpu-2
blocks:
main:
tasks:
echo:
name: Echo
args:
message: Hello from my first workflow!
Replace my-account with your account name.
nameis the name the platform shows for the workflow.compute_typeis the compute each task is allocated.cpu-2, two vCPUs, is plenty for this task.blocksholds the workflow's tasks. A run starts in the block namedmain.echois the task's key, andnamethe name its run shows for it.usesnames the task definition and version the task runs, andargsgives itsmessageinput a value.
2. Upload the workflow
swale workflow create \
--project-name my-first-project \
--file my-workflow.yaml
The platform checks the file as it uploads it: an unknown field, or a uses that names a task definition your account cannot use, fails the upload with an error that names the problem. On success the command prints the new workflow's ID, as Workflow created: <workflow-id>. Copy the ID: the next steps need it.
3. Start a run
swale workflow run start \
--project-name my-first-project \
--workflow-id <workflow-id>
Replace <workflow-id> with the ID from step 2. The command prints Workflow run started. Run ID: followed by the new run's ID.
4. Watch the run
- In the platform UI, open Projects from the sidebar and click
my-first-project. - In the sidebar, click Workflows, then click Echo workflow.
- Click the run in the workflow's list of runs.
The run's page shows its status and its Workflow Graph, where the Echo task moves from Pending through Starting and Running to Complete. The run itself then shows Finishing while its resources are released, and ends Complete. The page updates as the run moves, with no reload.
5. Read the task's log
Click the Echo task in the Workflow Graph. Its Task Details page opens, and its Logs card shows the line the task printed:
Hello from my first workflow!
If the run does not start
- The start is refused with a billing or email error. Starting a run needs a verified email and an Active billing status; see Billing statuses.
- The start is refused with an error about runs in progress. The account is at its limit on runs in progress; see Runs in progress.
- The task fails. Its failure reason is on its Task Details page, and the first entry of its log says what the platform resolved for it.
Permissions and restrictions lists what every operation requires.