Prism
v0.2.4
v0.2.4
  • 👋Welcome to Prism!
  • Getting Started
    • Installation
    • Creating your first project
    • Why Prism?
  • Fundamentals
    • Tasks
      • tasks
        • tasks.ref()
      • hooks
        • hooks.sql
        • hooks.spark
        • hooks.dbt_ref
        • hooks.get_connection
        • hooks.get_cursor
    • Targets
      • Multiple targets
    • Config files
      • prism_project.py
        • RUN_ID / SLUG
        • SYS_PATH_CONF
        • THREADS
        • PROFILE_YML_PATH / PROFILE
        • PRISM_LOGGER
        • TRIGGERS_YML_PATH / TRIGGERS
      • Profile YML
      • Triggers YML
    • Jinja
      • __file__ and Path
      • prism_project
      • wkdir
      • parent_dir
      • concat
      • env
  • Adapters
    • Overview
    • sql
      • BigQuery
      • Postgres
      • Redshift
      • Snowflake
      • Trino
      • Presto
    • PySpark
    • dbt
  • Agents
    • Overview
    • Docker
    • EC2
  • CLI
    • Command Line Interface
    • agent
      • apply
      • run
      • build
      • delete
    • compile
    • connect
    • create
      • agent
      • task
      • trigger
    • graph
    • init
    • run
    • spark-submit
  • Advanced features
    • Concurrency
    • Logging
    • Triggers
    • Retries
    • Python Client
    • Skipping tasks
  • API Reference
    • prism.task.PrismTask
    • @task(...)
    • @target(...)
    • @target_iterator(...)
    • TaskManager
      • tasks.ref(...)
    • PrismHooks
      • hooks.sql(...)
      • hooks.dbt_ref(...)
      • hooks.get_connection(...)
      • hooks.get_cursor(...)
    • 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.

PreviousSkipping tasksNext@task(...)

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(tasks: TaskManager, hooks: PrismHooks) -> 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).

  • Parameters

    • tasks: Instance of the class. This allows users to reference the output of other tasks within their task.

    • hooks: Instance of the class. This allows users to access adapter connections using a low-level API.

  • Outputs:

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

PrismTask.run(tasks: TaskManager, hooks: PrismHooks) -> Any

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

  • Parameters

    • tasks: Instance of the class. This allows users to reference the output of other tasks within their task.

    • hooks: Instance of the class. This allows users to access adapter connections using a low-level API.

  • Outputs:

    • Any non-null output.

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
# 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

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

TaskManager
PrismHooks
TaskManager
PrismHooks
RETRIES