Skip to content

Project Structure

Initialize and structure a Python workflow project so releases can be built reproducibly and release runners can discover and execute its tasks.

A Python workflow project contains task classes, a Runner definition, pyproject.toml, uv.lock, and a tilebox.workflow.toml configuration file. The Tilebox CLI uses these files to build a workflow release, discover registered tasks, and run them on release runners.

Scaffold a workflow project

Use the CLI to initialize a local Python workflow project from the built-in scaffold. For an end-to-end walkthrough through publishing and submitting your first job, see Build and deploy a workflow project.

bash
tilebox workflow init ./scene-qa --name "Scene QA"

Omit the directory argument to initialize the current directory, or omit --name to derive the project name from the directory. Add --description "Checks incoming scenes" to set the workflow description used on first publication.

The command writes the project files and runs uv sync to install dependencies and create uv.lock (requires uv on PATH):

  • scene-qa/
    • pyproject.toml
    • uv.lock
    • tilebox.workflow.toml
    • runner.py
    • .tilebox/
      • .gitignore
      • workflows.json
      • workflows.lock

Your project stays local until you run tilebox workflow publish-release, which creates the remote workflow and records its link in .tilebox/workflows.json.

Generated files

  • runner.py defines a starter HelloWorld task class with an explicit identifier() method, exports a runner = Runner(tasks=[HelloWorld]) instance for release discovery, and includes an if __name__ == "__main__" block so you can run the same file directly during local development (uv run python runner.py).
  • pyproject.toml and uv.lock declare Python (>=3.12), the Tilebox SDK packages (tilebox-workflows, tilebox-datasets), and dev tooling (pytest, ruff, ty), with exact versions pinned in uv.lock.
  • tilebox.workflow.toml points runner = "runner:runner" at the root runner.py module and selects pyproject.toml, uv.lock, and **/*.py for the release archive. See Workflow Configuration for all fields, exclude patterns, and deployment targets.
  • .tilebox/ stores local workflow link state (workflows.json and workflows.lock) plus a .gitignore (*) so link metadata stays untracked.
runner.py python
from tilebox.workflows import Client, ExecutionContext, Runner, Task


class HelloWorld(Task):
    name: str

    @staticmethod
    def identifier() -> tuple[str, str]:
        return "scene-qa/HelloWorld", "v0.1"

    def execute(self, context: ExecutionContext) -> None:
        context.logger.info(f"Hello, {self.name}!")


runner = Runner(tasks=[HelloWorld])


if __name__ == "__main__":
    runner.connect_to(Client()).run_forever()

Use explicit identifier() methods for tasks that will be published. Stable identifiers let existing jobs resume across refactors and compatible bug fixes.

Template projects

Use --template to start from the latest published release of a workflow you can access (owned by your organization or shared with it). Browse choices with tilebox workflow list --shared or tilebox workflow list:

bash
tilebox workflow init ./scene-qa \
  --template <template-reference> \
  --name "Scene QA"

Choose a new or empty directory. Template initialization copies the published release’s Python source, pyproject.toml, uv.lock, and reconstructed build/runner configuration (without deployment targets or files excluded from that release). It does not run uv sync or execute template code automatically; review the downloaded files, then run uv sync.

Use --name to give your copy a new project name (omitting the directory creates one from the name), and --description to replace the template description. Python packages and task names stay unchanged so you can start editing immediately. Your copy is independent: publishing creates your own workflow and leaves the template untouched.

Growing into a package

Start by editing runner.py directly. As a workflow grows, split task classes into modules or a package importable from the project root:

  • scene-qa/
    • pyproject.toml
    • uv.lock
    • tilebox.workflow.toml
    • runner.py
    • scene_qa/
      • __init__.py
      • tasks.py

Because the default [build] include pattern (**/*.py) already covers subdirectories, moving tasks into scene_qa/tasks.py and importing them from runner.py works without changing tilebox.workflow.toml. If you move runner.py inside the package (such as scene_qa/runner.py), update runner = "scene_qa.runner:runner" in tilebox.workflow.toml.

If you assemble a project manually instead of using tilebox workflow init, link it to an existing workflow before publishing.

Version control and artifact hygiene

Commit your Python source files, pyproject.toml, uv.lock, and tilebox.workflow.toml. Keep .venv/ and .tilebox/ out of version control. After cloning a repository, link your checkout to the workflow you want to publish to.

Keep release artifacts small: include only code, lock files, and small configuration, and fetch large models or datasets lazily at runtime. See Workflow Releases for guidance.

Type to search…