Chapters
Related content
If you want to dive into detail, refer to the following pages:
Workflows can be used to process batches of data, ensuring each item in the batch goes through a defined process with reliable execution. This section demonstrates processing a batch of puns using the Punderful application as an example.
Chapters
Related content
If you want to dive into detail, refer to the following pages:
The Punderful application processes user-submitted puns by performing content moderation, creating embeddings, categorizing, and adding them to a vector store. This process is defined as a Workflow. To process a batch of existing puns (from an open-source dataset called OPun), a batch endpoint is created that iterates through the puns and triggers the defined Workflow for each one.
The following code snippet shows the endpoint responsible for batch processing:
This code:
puns.json
).insertPun
).PUBLISH
Workflow for each individual pun using c.env.PUBLISH.create()
. The Workflow is given a unique ID using crypto.randomUUID()
.The Cloudflare Wrangler CLI provides commands to monitor and manage Workflows and their instances.
To list the available workflows associated with your account:
npx wrangler workflows list
To list the instances of a specific workflow (for example, the publish
workflow):
npx wrangler workflows instances list publish
This command will show a list of workflow instances, their status (Queued, Running, Completed, Errored), and timestamps.
To view the details of a specific workflow instance, including its steps and their status, duration, and output:
npx wrangler workflows instances describe publish <instance-id>
Replace <instance-id>
with the actual ID of a running or completed instance from the list
command output.
Describing a workflow instance provides a detailed breakdown of its execution:
Workflow Name: publishInstance ID: oPun-batch-aea07d75-95fa-448f-9573-6e435388eff7Version ID: 75665fce-24a1-4c83-a561-088aabc91e5fStatus: CompletedTrigger: APIQueued: 10/24/2024, 1:43:45 AMSuccess: YesStart: 10/24/2024, 1:43:45 AMEnd: 10/24/2024, 1:43:49 AMDuration: 4 secondsLast Successful Step: update-status-to-published-1Steps:
Name: content-moderation-1Type: StepStart: 10/24/2024, 1:43:45 AMEnd: 10/24/2024, 1:43:45 AMDuration: 0 secondsSuccess: YesOutput: "true"Config: {"retries":{"limit":5,"delay":1000,"backoff":"exponential"},"timeout":"10 minutes"}Attempts: Status: Completed Start Time: Oct 23, 2024 6:44:57 PM End Time: Oct 23, 2024 6:44:57 PM Wall Time: 180 ms... (additional steps like create-pun-embedding-1, categorize-pun-1, add-embeddings-to-vector-store-1, update-status-to-published-1)
This output shows the status, start/end times, duration, success status, and even the output and configuration for each step within the workflow instance.
You can also monitor Workflows and their instances directly in the Cloudflare Dashboard.
This dashboard view provides a user-friendly way to observe the progress of your batch jobs, identify failed instances, and inspect the execution details of each step.