Available Runtime Variables

In order to access information about the runtime while running a task, you can use the context value.

context includes important contextual information about the runtime, like the current task_id and callback_url.

Field NamePurpose
container_idUnique identifier for a container
stub_idIdentifier for a stub
stub_typeType of the stub (function, endpoint, taskqueue, etc)
callback_urlURL called when the task status changes
task_idIdentifier for the specific task
timeoutMaximum time allowed for the task to run (seconds)
on_start_valueAny values returned from the on_start function
bind_portPort number to bind a service to
python_versionVersion of Python to be used

Using a Runtime Variable

Any of the fields above can be accessed on the context variable:

from beam import task_queue

@task_queue()
def handler(context):
    task_id = context.task_id
    return {}