# CurrentRun.ref()

`CurrentRun.ref` has two important jobs.

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 `taskA` *before* `taskB`.

Here's the full method definition:

```python
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
    """
```

## Example

{% tabs %}
{% tab title="Class-based tasks" %}
{% code lineNumbers="true" %}

```python
# tasks/hello_world.py

import prism.task
import prism.target

class HelloWorld(prism.task.PrismTask):
    
    def run(self):
        test_str = "Hello, world!"
        return test_str
```

{% endcode %}

{% code lineNumbers="true" %}

```python
# tasks/second_task.py

import prism.task
import prism.target
from prism.runtime import CurrentRun

class SecondTask(prism.task.PrismTask):
    
    def run(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
```

{% endcode %}
{% endtab %}

{% tab title="Function-based tasks" %}
{% code lineNumbers="true" %}

```python
# tasks/hello_world.py

from prism.decorators import task

@task()
def hello_world():
    test_str = "Hello, world!"
    return test_str
```

{% endcode %}

{% code lineNumbers="true" %}

```python
# tasks/second_task.py

import prism.decorators import task

@task()
def second_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
```

{% endcode %}
{% endtab %}
{% endtabs %}

Our `CurrentRun.ref()` is located in the second task. We did not specify any custom [task ID](https://docs.runprism.com/tasks#task-ids) in our `HelloWorld` task, so we need to reference the default task ID that Prism sets — `<module_name>.<class name>`.
