Skip to content

armgit / txtai

Public Imported from GitHub
0

πŸ’‘ All-in-one AI framework for semantic search, LLM orchestration and language model workflows

2.2 KB
Raw Blame

Schedule

schedule schedule

Workflows can run on a repeating basis with schedules. This is suitable in cases where a workflow is run against a dynamically expanding input, like an API service or directory of files.

The schedule method takes a cron expression, list of static elements (which dynamically expand i.e. API service, directory listing) and an optional maximum number of iterations.

Below are a couple example cron expressions.

# β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ minute (0 - 59)
# | β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ hour (0 - 23)
# | | β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ day of the month (1 - 31)
# | | | β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€ month (1 - 12)
# | | | | β”Œβ”€β”€β”€β”€β”€β”€β”€ day of the week (0 - 6)
# | | | | | β”Œβ”€β”€β”€β”€β”€ second (0 - 59)
# | | | | | |
  * * * * * *      # Run every second
0/5 * * * *        # Run every 5 minutes
  0 0 1 * *        # Run monthly on 1st
  0 0 1 1 *        # Run on Jan 1 at 12am
  0 0 * * mon,wed  # Run Monday and Wednesday

Python

Simple workflow scheduled with Python.

workflow = Workflow(tasks)
workflow.schedule("0/5 * * * *", elements)

See the link below for a more detailed example.

Notebook Description
Workflow Scheduling Schedule workflows with cron expressions Open In Colab

Configuration

Simple workflow scheduled with configuration.

workflow:
  index:
    schedule:
      cron: 0/5 * * * *
      elements: [...]
    tasks: [...]
# Create and run the workflow
from txtai import Application

# Create and run the workflow
app = Application("workflow.yml")

# Wait for scheduled workflows
app.wait()

See the links below for more information on cron expressions.