Skip to main content

Getting Started

caution

We are not in production yet, so all the usual "alpha software" warnings apply. Reach out to us on Discord, Github, or email for help!

Install the CLI

Run the following command. See Reference for more detail.

curl -L https://raw.githubusercontent.com/usecakework/cakework/main/cli/install.sh | sh

Create an account

Sign up for a Cakework account.

cakework signup

If you're running from a machine where you cannot open a browser window, you can run in headless mode.

cakework signup --headless

Build Your Tasks

Create a New Project

Create a new Project with the Cakework CLI. We use Poetry for dependency management to make sure no dependencies get accidentally installed.

cakework new yummy
cd yummy

Write Your Task

You write Tasks as Python functions and add them to your Project using the Task SDK. You pass parameters in with a JSON-serializable dict and can return any JSON-serializable object.

Here is sample code from your autogenerated src/main.py.

# Write your task as a Python function
from cakework import Cakework

def say_hello(params):
return "hello " + params['name']

if __name__ == "__main__":
# Instantiate your project with a name
cakework = Cakework("hello_world")
# Add your task to your project
cakework.add_task(say_hello)

Deploy Your Task

Deploy your Task to Cakework!

cakework deploy

Run a Task

Once your Task is deployed, you can run it using the Cakework client SDKs.

Generate Client Token

You need to generate a token to authenticate your client with your Project. Keep your token safe.

cakework create-client-token a-clienttoken

Use the Client

You run your Task by instantiating a client. Starting a Task creates a Run with an id that you can use to get the status or result of processing. The result of the Run is the what your Task function returns.

Here is sample code that shows how to instantiate a client and run a Task.

from cakework import Client
import time

if __name__ == "__main__":

# Instantiate a client with the project you created, and pass in your client token.
client = Client("yummy", "CLIENT_TOKEN")

# Start your task.
run_id = client.run("say_hello", {"name": "Jessie"}, "compute"={cpu: 1, memory: 512})

# Poll the task until completion.
status = client.get_run_status(run_id)
while (status == "PENDING" or status == "IN_PROGRESS"):
time.sleep(1)
print(status)
status = client.get_run_status(run_id)

# Get the result once the task is complete!
if (client.get_run_status(run_id) == "SUCCEEDED"):
result = client.get_run_result(run_id)
print(result)

Set CPU / Memory

You can control your compute parameters per run with the compute argument to each run. This is an optional parameter and defaults to a 1 CPU and 512MB of memory. CPU can be between 1 and 8, and memory (MB) can be between 256 and 16384.

run_id = client.run("say_hello", {"name": "Jessie"}, compute={"cpu": 1, "memory": 1024})

More!

Installing Dependencies

We use Poetry for dependency management. You can use Poetry commands as normal. Use poetry add to install a new dependency.

If you have a more complicated dependency situation, you can modify the generated Dockerfile.

Task Python Version

By default, we create new Cakework projects in your system Python version. You can change this with Poetry using poetry env use but you also need to update the Dockerfile. Modify the FROM python:PYTHONVERSION-slim-buster line to the version of Python you're using.

Error Handling

Any uncaught exceptions or errors in your task function will send your task to a FAILED status.

Monitoring and Debugging

You can use the CLI to find tasks that failed, using cakework task logs --status FAILED <projectName> <taskName>.

You can grab logs for any run using cakework run logs <run>.

Local Development

Coming soon!