tasks
In the previous section, we saw that the run
function in a PrismTask
needs to have two parameters: tasks
, and hooks
:
Both are critical for Prism to run, and Prism will throw an error if it finds a run
function without both of the parameters.
So what does tasks
do? Simply put, it allows users to reference and access other tasks' outputs via the ref(...)
function. This is the most important function in Prism. It is impossible to build even moderately complex workflows without it.
Important: To retrieve the output of a different task, simply pass in the module name where that tasks lives, e.g., tasks.ref("<module name here>")
.
Let's say that you want to create a new task that builds off of the "Hello, world!"
string created in task HelloWorld
above. You could do that as follows:
Under the hood, Prism does three things:
It parses each file and computes all
tasks.ref(...)
calls.Then, it builds a dependency graph based on which files reference others. In the above example, Prism knows that the task in
hello_world.py
should be run before the task insecond_task.py
.It keeps track of the return value for each task and spits out the desired task's return value for each
tasks.ref(...)
call.
Important: tasks.ref(...)
is one of the most important functions in Prism – it is impossible to build event moderately complex workflows without it.
Last updated