Prism
v0.2.2
v0.2.2
  • 👋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
  • 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
  1. API Reference
  2. TaskManager

tasks.ref(...)

Function used to retrieve the output of other tasks.

tasks.ref(task_name: str, local: bool = False)

  • Parameters

    • task: str: the name of the task whose output you'd like to retrieve. This name should be in the form <module_name>, or <module_name>.<task_name>, where <task_name> is the name of the Prism task class / function.

    • local: bool: whether task lives in the same module. The default is False.

Examples:

Non-local tasks:

import prism.task
import prism.target
import prism.decorators

class ExampleTask(prism.task.PrismTask):
    
    @prism.decorators.target(
        type=prism.target.Txt, 
        loc="/Users/hello_world.txt",
        **kwargs
    )
    def run(self, tasks, hooks):
        test_str = "Hello, world!"

        # Get output from task in first_task.py. If this module
        # contains multiple tasks, then we'll need to specify
        # the task via <module_name>.<task_name>
        previous_task_output = tasks.ref("first_task")
        return test_str + previous_task_output
from prism.decorators import task

@task()
def example_function(tasks, hooks):
    test_str = "Hello, world!"
    
    # Get output from task in first_task.py. If this module
    # contains multiple tasks, then we'll need to specify
    # the task via <module_name>.<task_name>
    previous_task_output = tasks.ref("first_task")

    return test_str + previous_task_output

Local tasks:

import prism.task
import prism.target
import prism.decorators

class FirstTask(prism.task.PrismTask):
    
    def run(self, tasks, hooks):
        # do something


class ExampleTask(prism.task.PrismTask):
    
    @prism.decorators.target(
        type=prism.target.Txt, 
        loc="/Users/hello_world.txt",
        **kwargs
    )
    def run(self, tasks, hooks):
        test_str = "Hello, world!"
        previous_task_output = tasks.ref("FirstTask", local=True)
        return test_str + previous_task_output
from prism.decorators import task

@task()
def first_task(tasks, hooks):
    # do something


@task()
def example_function(tasks, hooks):
    test_str = "Hello, world!"
    previous_task_output = tasks.ref("first_task", local=True)
    return test_str + previous_task_output
PreviousTaskManagerNextPrismHooks