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
  1. API Reference

@target(...)

Decorator used to write the output of a task function.

prism.decorators.target(*, type: prism.target.PrismTarget, loc: Union[str, pathlib.Path])

  • Parameters

    • *: indicates that the target decorator only accepts keyword arguments.

    • type: a valid Prism target. This controls the output type, e.g., a .txt file, a .csv, a .json, etc. Prism targets are classes that inherit the prism.target.PrismTarget class and implement the save method. See here.

    • loc: a string or path-like object that controls where the output saved.

Example:

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):
        test_str = "Hello, world!"
        return test_str
from prism.decorators import task, target
import prism.target

@task(
    targets=[
        target(type=prism.target.Txt, loc="/Users/hello_world.txt")
    ]
)
def example_function(tasks, hooks):
    test_str = "Hello, world!"
    return test_str

Previous@task(...)Next@target_iterator(...)

Last updated 1 year ago