Skip to content

How to create a new tasks collection

For asynchronous workloads triggered by PubSub, or running tasks regularly on schedules we have a library called ucam-faas which can be used to build task collections that run these jobs.

Read our explanation of the tasks environment if you're unsure whether the boilerplate is right for you.

You may instead want to add a task into an existing webapp if the task is tightly coupled to the web application and/or will need to share code with it. In this case read our guide for adding tasks into a web application.

Prepare your system

If you have not already done so, make sure you have followed our how-to guide for preparing your system and installed the software which it recommends.

We use the copier to apply our webapp templates. Make sure that it is installed on your system via:

python3 -m pip install --user copier

Create the collection

Info

More information on working with copier templates is available on a dedicated page.

Start the template process via:

copier copy --trust --vcs-ref <TAG> \
https://gitlab.developers.cam.ac.uk/uis/devops/tasks-boilerplate.git <OUTPUT_PATH>

Where:

  • <TAG> is a version of the template (For example, 2.0.0. See the available tags on GitLab.)
  • <OUTPUT_PATH> is a path where generated content will be stored. Can be relative or absolute.

Answer each question or press Enter to accept the default.

Your task collection is created in a directory you specify in <OUTPUT_PATH>. Change to that directory and check that the tests pass:

$ cd {name-of-generated-directory}
$ poetry install
Installing dependencies from lock file
...
$ poetry poe pytest:local
Poe => pytest
============================= test session starts ==============================
platform darwin -- Python 3.13.9, pytest-9.0.2, pluggy-1.6.0
rootdir: /Users/mikek/tmp/task-template-test
configfile: pyproject.toml
plugins: anyio-4.12.1, env-1.6.0, pytest_docker_tools-3.1.9
collected 1 item

test_tasks/tests/test_main.py .                                          [100%]

============================== 1 passed in 0.98s ===============================

Summary

In this guide you learned how to create a new tasks collection using our template.

Next steps