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. Advanced features

Skipping tasks

Starting in version v0.2.3, users can now skip tasks during project runs if certain, user-defined conditions are met. These conditions should be defined in PrismTask's done method:

# tasks/hello_world.py

import prism.task
import prism.target
import prism.decorators
from pathlib import Path

class HelloWorld(prism.task.PrismTask):
    
    def done(self):
        return Path("/Users/hello_world.txt").is_file()

    @prism.decorators.target(
        type=prism.target.Txt, 
        loc="/Users/hello_world.txt", 
        **kwargs
    )
    def run(self):
        test_str = "Hello, world!"
        return test_str

In the above example, the hello_world.HelloWorld task is skipped if the /Users/hello_world.txt file exists.

PreviousRetriesNextprism.task.PrismTask

Last updated 1 year ago

Important: although the done method doesn't need to reference a target, it almost always should! Otherwise, future tasks may a target that doesn't have any data.

ref