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, tasks, hooks):
        return Path("/Users/hello_world.txt").is_file()

    @prism.decorators.target(
        type=prism.target.Txt, 
        loc="/Users/hello_world.txt", 
        **kwargs
    )
    def run(self, tasks, hooks):
        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.

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

This is what a skipped task looks like in the logs:

$ prism run
--------------------------------------------------------------------------------
<HH:MM:SS> | INFO  | Running with prism v0.2.5...
<HH:MM:SS> | INFO  | Found project directory at /my_first_project
 
<HH:MM:SS> | INFO  | RUNNING 'parsing prism_project.py'.............................................. [RUN]
<HH:MM:SS> | INFO  | FINISHED 'parsing prism_project.py'............................................. [DONE in 0.03s]
<HH:MM:SS> | INFO  | RUNNING 'task DAG'.............................................................. [RUN]
<HH:MM:SS> | INFO  | FINISHED 'task DAG'............................................................. [DONE in 0.01s]
<HH:MM:SS> | INFO  | RUNNING 'creating pipeline, DAG executor'....................................... [RUN]
<HH:MM:SS> | INFO  | FINISHED 'creating pipeline, DAG executor'...................................... [DONE in 0.01s]
 
<HH:MM:SS> | INFO  | ===================== tasks (vermilion-hornet-Gyycw4kRWG) =====================
<HH:MM:SS> | INFO  | 1 of 2 RUNNING EVENT 'hello_world.HelloWorld'................................... [RUN]
<HH:MM:SS> | INFO  | 1 of 2 SKIPPING EVENT 'hello_world.HelloWorld'.................................. [SKIP]
...
...
<HH:MM:SS> | INFO  | Done!
--------------------------------------------------------------------------------