# Workflow

## *class* <mark style="color:purple;">Workflow</mark>

Workflows on Redivis are where analytical pipelines are built and executed. All workflows are owned by a user, and are made up of transforms, notebooks, and their output tables.

{% hint style="warning" %}
Workflows were previously referred to as "Projects" on Redivis. Existing code that utilized the "project" terminology will continue to work (e.g., `User$list_projects()`).&#x20;

However, we encourage users to migrate their code to prevent future issues and confusion.
{% endhint %}

## Constructors

<table><thead><tr><th width="370.3046875">Method</th><th>Description</th></tr></thead><tbody><tr><td><a href="/pages/Jipu0f3WVW0WHeyegm5H"><strong><code>redivis$current_workflow</code></strong></a>()</td><td>Get the current default workflow. Typically called within notebooks.</td></tr><tr><td><a href="/pages/lbZ24zN5UE43JUmMhZBq"><strong><code>Organization$list_workflows</code></strong></a>([max_results])</td><td>List all workflows in the organization.</td></tr><tr><td><a href="/pages/wQ5QvftwEe3cdynAXyRS"><strong><code>User$list_workflows</code></strong></a>([max_results])</td><td>List all workflows owned by a user.</td></tr><tr><td><a href="/pages/3DAt0UdJ4Hzk42SbnGpv"><strong><code>Organization$workflow</code></strong></a>(name)</td><td>Construct a new workflow instance that references a workflow owned by an organization.</td></tr><tr><td><a href="/pages/cQVfhz8BgMm5lQyGl8a8"><strong><code>User$workflow</code></strong></a>(name)</td><td>Construct a new workflow instance that references a workflow owned by a user.</td></tr></tbody></table>

## Examples

{% tabs %}
{% tab title="Basics" %}

<pre class="language-r"><code class="lang-r">library("redivis")

workflow &#x3C;- redivis$user("imathews")$workflow("example_workflow_climate_analysis")
tables &#x3C;- workflow$list_tables()

for (table in tables){
<strong>    # Properties will be populated with the table.list resource representation
</strong>    print(table$properties) 
    
    table$get()
    # Properties will now be populated with the table.get resource representation
    print(table$properties) 
}

workflow$table("join_lat_lon_output")$exists() # -> TRUE
</code></pre>

{% endtab %}

{% tab title="Scoped queries" %}

```r
library("redivis")

workflow <- redivis$user("imathews")$workflow("example_workflow_climate_analysis")

query = workflow$query("
    SELECT
        id,
        EXTRACT(YEAR FROM date) AS year,
        SUM(value) AS annual_precip
    FROM daily_observations
    WHERE (element = 'PRCP')
    GROUP BY id, year
")

query$to_tibble()
# 	id	        year	    annual_precip
# 0	CA0023026HN	2003	    2925.0
# ...
```

{% endtab %}
{% endtabs %}

## Fields

| **`properties`**          | <p>A named list containing the <a href="/pages/tdGF9MCxwWhySoWzAc4I">API resource representation of the workflow</a>. <br><br>This will be fully populated after calling <a href="/pages/Nxwm0510PiVEII2ttJCm">Workflow$get()</a>, and partially populated for worfklows created via <a href="/pages/wQ5QvftwEe3cdynAXyRS">User$list\_workflows</a>. Otherwise will be <code>NULL</code>.</p> |
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`qualified_reference`** | The [fully qualified reference](/api/referencing-resources.md) for the workflow, which can be used in SQL queries or the REST API. E.g., `imathews.example_workflow_climate_analysis:x7kh`                                                                                                                                                                                                    |
| **`organization`**        | A reference to the [Organization](/api/client-libraries/redivis-r/reference/organization.md) instance that constructed this workflow.                                                                                                                                                                                                                                                         |
| **`scoped_reference`**    | The canonical reference for the workflow, without the username qualifier. E.g.,: `example_workflow_climate_analysis:x7kh`                                                                                                                                                                                                                                                                     |
| **`user`**                | A reference to the [User](/api/client-libraries/redivis-r/reference/user.md) instance that constructed this workflow.                                                                                                                                                                                                                                                                         |

## Methods

<table data-header-hidden><thead><tr><th width="441"></th><th></th></tr></thead><tbody><tr><td><a href="/pages/Qtx7CuiRGzFqfdOiOSc5"><strong><code>Workflow$connect_dbi</code></strong></a>()</td><td>Create a DBI connection scoped to the workflow.</td></tr><tr><td><a href="/pages/NWW0qFiZzgt8vmG6mAVb"><strong><code>Workflow$datasource</code></strong></a>()</td><td>Create a reference to a datasource within the workflow.</td></tr><tr><td><a href="/pages/VPIDlTDByECL2iYUJ9yT"><strong><code>Workflow$exists</code></strong></a>()</td><td>Check whether the workflow exists.</td></tr><tr><td><a href="/pages/Nxwm0510PiVEII2ttJCm"><strong><code>Workflow$get</code></strong></a>()</td><td>Get the workflow, populating the <code>properties</code> attribute on the current instance.</td></tr><tr><td><a href="/pages/TMtsqlnwI0DWrAVutuAs"><strong><code>Workflow$list_datasources</code></strong></a>([max_results])</td><td>List all datasources in the workflow.</td></tr><tr><td><a href="/pages/KTrQRx7EQvmdqhdwUH0q"><strong><code>Workflow$list_notebooks</code></strong></a>([max_results])</td><td>List all notebooks in the workflow.</td></tr><tr><td><a href="/pages/ldwguVr960XK4IQgVUyg"><strong><code>Workflow$list_parameters</code></strong></a>([max_results])</td><td>List all parameters in the workflow.</td></tr><tr><td><a href="/pages/xN4go4b1Js8zBvlmvLd0"><strong><code>Workflow$list_tables</code></strong></a>([max_results])</td><td>List all tables in the workflow.</td></tr><tr><td><a href="/pages/DyvtadD3m8pwX68wli5C"><strong><code>Workflow$list_transforms</code></strong></a>([max_results])</td><td>List all transforms in the workflow.</td></tr><tr><td><a href="/pages/k5dPdjTCqkG4TcAGt6lP"><strong><code>Workflow$notebook</code></strong></a>(name)</td><td>Create a reference to a specific notebook within the workflow.</td></tr><tr><td><a href="/pages/wlLiet7FWiedvkkYXzGQ"><strong><code>Workflow$parameter</code></strong></a>(name)</td><td>Create a reference to a specific parameter within the workflow.</td></tr><tr><td><a href="/pages/6OvdQSGHKVBT1siwb9lo"><strong><code>Workflow$query</code></strong></a>(query_string)</td><td>Create a query scoped to the workflow.</td></tr><tr><td><a href="/pages/CVDE36VyVVwAHkSOzpsJ"><strong><code>Workflow$table</code></strong></a>(table_reference)</td><td>Create a reference to a specific table within the workflow.</td></tr><tr><td><a href="/pages/Vgn3smNTrgYO3VLAe5Wq"><strong><code>Workflow$transform</code></strong></a>(name)</td><td>Create a reference to a specific transform within the workflow.</td></tr><tr><td><a href="/pages/Nx9uouernPacmrpBNemt"><strong><code>Workflow$update_variables</code></strong></a>(variables)</td><td>Bulk update variable metadata across tables in a workflow.</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.redivis.com/api/client-libraries/redivis-r/reference/workflow.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
