Running a function remotely

You can add a decorator to any Python function to run it remotely on Beam:

app.py
from beam import function


@function()
def handler():
    return {"hello world"}

if __name__ == "__main__":
    handler.remote()

By default, Beam will sync all the files in your working directory to the remote container. This allows you to use the files you have locally while developing. If you want to prevent some files from getting uploaded, you can create a .beamignore.

Passing function args

You can pass JSON arguments to your function, using the -d command in the CLI:

python app.py -d '{"x": "10"}'

Task timeouts

You can set timeouts on tasks. Timeouts are set in seconds:

from beam import function

# Set a 24 hour timeout
@function(timeout=86400)
def handler():
    return {"hello world"}

# Disable timeouts completely
@function(timeout=-1)
def handler():
    return {"hello world"}