Prism
v0.3.0
v0.3.0
  • 👋Welcome to Prism!
  • Getting Started
    • Installation
    • Creating your first project
    • Why Prism?
  • Fundamentals
    • PrismProject API
      • PrismProject().run
      • PrismProject().graph
    • Tasks
    • Targets
      • Multiple targets
    • CurrentRun API
      • CurrentRun.ref()
      • CurrentRun.conn()
      • CurrentRun.ctx()
  • Connectors
    • Overview
    • BigQueryConnector
    • PostgresConnector
    • RedshiftConnector
    • SnowflakeConnector
    • TrinoConnector
    • PrestoConnector
  • CLI
    • Command Line Interface
    • graph
    • init
    • run
  • Advanced features
    • Concurrency
    • Logging
    • Callbacks
    • Retries
    • Skipping tasks
  • API Reference
    • prism.task.PrismTask
    • @task(...)
    • @target(...)
    • @target_iterator(...)
    • prism.target.PrismTarget
  • Use Cases
    • Analytics on top of dbt
    • Machine Learning
  • Wiki
    • DAGs
Powered by GitBook
On this page
  • Constructor
  • Methods
  • Attributes and underlying data
  1. API Reference

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.

Methods

PrismTask.done() -> bool

Check if this task is already done. If this task is already done, then the task will be skipped. If not, it will be executed.

Note that if the --full-refresh option is specified, then all tasks are run from scratch (even the ones that are done).

  • Outputs:

    • True if the task is already done. False otherwise.

PrismTask.run() -> Any

Core logic for your task. This task must return a non-null output.

  • Outputs:

    • Any non-null output.

Attributes and underlying data

PrismTask.task_id

The ID to associate with the task. The default is <module_name>.<class name>.

# tasks/example_task.py

import prism.task

class ExampleTask(prism.task.PrismTask):
    task_id = "dummy_example"  # if this were not specified, then the task ID would be example_task.ExampleTask
    
    def run(self):
        test_str = "Hello, world!"
        return test_str
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):
        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):
        test_str = "Hello, world!"
        return test_str
PreviousSkipping tasksNext@task(...)

Last updated 1 year ago