tasks
In the previous section, we saw that tasks 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 task 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:
Important: in previous versions of Prism,tasks.ref()
argument required the .py
suffix (e.g., tasks.ref('hello_world.py')
). Starting in version 0.2.0rc1
, this suffix should be removed from the argument. In other words:
tasks.ref('hello_world.py') --> tasks.ref('hello_world')
If you leave the .py
suffix in, then Prism will throw a warning.
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