Robocorp Tasks

4.1.1 · active · verified Thu Apr 16

robocorp-tasks is a Python framework designed to simplify the development of Python automations by providing a runner for tasks, offering logging out of the box, and managing the lifecycle for running such tasks. It is currently at version 4.1.1 and receives continuous updates as part of the broader Robocorp/Sema4.ai ecosystem.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart defines a basic Robocorp task using the `@task` decorator. It uses `robocorp.log` for output and demonstrates how to access environment variables. Tasks are executed via the `python -m robocorp.tasks run` command, specifying the file or directory and optionally the task name.

import os
from robocorp.tasks import task
from robocorp import log

@task
def hello_robocorp_world():
    """A simple Robocorp task that logs a message."""
    name = os.environ.get('ROBOCORP_USER_NAME', 'World')
    log.info(f"Hello, {name} from Robocorp!")
    log.critical("This is a critical log message.")
    log.debug("This is a debug message.")

# To run: Save as tasks.py and execute 'python -m robocorp.tasks run tasks.py'
# You can also use 'python -m robocorp.tasks run . -t hello_robocorp_world' in a directory.

view raw JSON →