First, it's used to reference the output of tasks within your project. Remember, tasks have to return a non-null output (either themselves, if the task is a decorated function or via their run method if the task is a class). At runtime, Prism stores references to these outputted objects and makes them accessible via CurrentRun.ref(...).
Second, it's used to build a dependency graph between tasks. Put another way, Prism parses the CurrentRef.ref(...) calls and figures out the order in which tasks need to be run — if taskB calls CurrentRef.ref("taskA") in its body, then Prism knows to run taskAbeforetaskB.
Here's the full method definition:
CurrentRun.ref(task_id: str) -> Any:""" Get the output of task with ID `task_id` args: task_id: ID of task from which to retrieve output returns: the output of the inputted `task_id` raises: prism.exception.RefDoesNotExistException if the task ID is not found """
# tasks/second_task.pyimport prism.taskimport prism.targetfrom prism.runtime import CurrentRunclassSecondTask(prism.task.PrismTask):defrun(self): hello_world_str = CurrentRun.ref("hello_world.HelloWorld")# default task ID set by Prism additional_details ="\n"+"This is a Prism project"!return hello_world_str + additional_details
# tasks/second_task.pyimport prism.decorators import task@task()defsecond_task(): hello_world_str = tasks.ref("hello_world.hello_world")# default task ID set by Prism additional_details ="\n"+"This is a Prism project"!return hello_world_str + additional_details
Our CurrentRun.ref() is located in the second task. We did not specify any custom task ID in our HelloWorld task, so we need to reference the default task ID that Prism sets — <module_name>.<class name>.