prism.task.PrismTask

Abstract class used to define tasks in a Prism project.

Constructor

prism.task.PrismTask

class prism.task.PrismTask(bool_run: bool = True, func: Optional[Callable[..., Any]] = None)

  • Parameters

    • bool_run: a boolean indicating whether to run the task. Default is True.

    • func: optional callable that overwrites the run function. Default is None.

Warning: you will never need to worry about instantiating a PrismTask class and setting bool_run / func when working with your tasks. This is all handled on the backend.

Attributes and underlying data

PrismTask.RETRIES

Number of times to retry a task upon failure. Default is 0.

# tasks/example_task.py

import prism.task

class ExampleTask(prism.task.PrismTask):
    
    RETRIES = 1
    
    def run(self, tasks, hooks):
        test_str = "Hello, world!"
        return test_str
PrismTask.RETRY_DELAY_SECONDS

Number of seconds to wait in between task retries. Default is 0. Must be specified alongside RETRIES.

# tasks/example_task.py

import prism.task

class ExampleTask(prism.task.PrismTask):
    
    RETRIES = 1
    RETRY_DELAY_SECONDS = 60
    
    def run(self, tasks, hooks):
        test_str = "Hello, world!"
        return test_str