# Notebook

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

An interface for working with notebooks on Redivis.

## Constructors

<table data-header-hidden><thead><tr><th width="368">Method</th><th>Description</th></tr></thead><tbody><tr><td><a href="/pages/cp2i7VzuMRQA9w6fM8JU"><strong><code>redivis.current_notebook</code></strong></a>()</td><td>Get a reference to the current notebook. Can only be called from within a running Redivis notebook.</td></tr><tr><td><a href="/pages/ymmdCHOkJE3I849oNpLZ"><strong><code>redivis.notebook</code></strong></a>(name)</td><td>Create a reference to a notebook based on its (qualified) name</td></tr><tr><td><a href="/pages/rnm6p1HKwFzPovNrK15R"><strong><code>Workflow.notebook</code></strong></a>()</td><td>Return a notebook within a specific <a href="/pages/KOkANjKjjVdEbbzoR2nH">workflow</a>. </td></tr><tr><td><a href="/pages/sZLDUnBl8lxc106OH1oO"><strong><code>Workflow.list_notebooks</code></strong></a>()</td><td>Returns a list of Notebooks within a workflow</td></tr></tbody></table>

## Examples

{% tabs %}
{% tab title="Run a notebook" %}

<pre><code><strong>username = "imathews"
</strong>workflow_name = "example_workflow_climate_analysis:x7kh"
notebook_name = "visualize_precipitation_trends:2f2v"

notebook = redivis.notebook(f"{username}.{workflow_name}.{notebook_name}")
notebook.run()
</code></pre>

{% endtab %}

{% tab title="Create a notebook output table" %}

```python
df = get_dataframe_somehow()

notebook = redivis.current_notebook()

# Create an output table on the current notebook
# Optional parameter, append (default False), determines whether the output appends to
#  or replaces the output table.
notebook.create_output_table(df, append=False) 

# Can also pass a path to a parquet file or csv
notebook.create_output_table("path/to/file.parquet")
```

{% endtab %}
{% endtabs %}

## Attributes

<table data-header-hidden><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><strong><code>workflow</code></strong></td><td>A reference to the <a href="/pages/KOkANjKjjVdEbbzoR2nH">Workflow</a> instance that is associated with this notebook.</td></tr><tr><td><strong><code>properties</code></strong></td><td>A dict containing the <a href="/pages/zl017567MUtuOo7Ug3l5">API resource representation of the notebook</a>. This will only be populated after certain methods are called, particularly the <code>get</code> method, and will otherwise be <code>None</code>.</td></tr><tr><td><strong><code>qualified_reference</code></strong></td><td><p></p><p>The <a href="/pages/-LzsPrAlHWxazTnhQQJE">fully qualified reference</a> to this notebook</p><p>For example,</p><pre class="language-http"><code class="lang-http">imathews.example_workflow_climate_analysis:x7kh.visualize_precipitation_trends:2f2v
</code></pre></td></tr><tr><td><strong><code>scoped_reference</code></strong></td><td>The canonical reference for the notebook, without any qualifiers. E.g., <code>visualize_precipitation_trends:2f2v</code></td></tr></tbody></table>

## Methods

<table data-header-hidden><thead><tr><th width="368">Method</th><th>Description</th></tr></thead><tbody><tr><td><a href="/pages/tQq1rBbDkioDZI83O7L0"><strong><code>notebook.create_output_table</code></strong></a>(data[, ...])</td><td>Create or append to an output table, using data from within the (running) notebook.</td></tr><tr><td><a href="/pages/rR8zcN7KqsXJBG5A96RT"><strong><code>notebook.get</code></strong></a>()</td><td>Fetches the notebook, after which notebook.properties will contain a dict with entries corresponding to the properties on the <a href="/pages/zl017567MUtuOo7Ug3l5">notebook resource definition</a>. Will raise an error if the notebook does not exist.</td></tr><tr><td><a href="/pages/8vcu8mnsSmDJkx2y39mu"><strong><code>notebook.exists</code></strong></a>()</td><td>Check whether the notebook exists.</td></tr><tr><td><a href="/pages/SGYdfkzGMajbWHi7wQhH"><strong><code>notebook.output_table</code></strong></a>()</td><td>Get a reference to the notebook's output table, if it exists.</td></tr><tr><td><a href="/pages/oXdtGtTzNDhybWfkM0LM"><strong><code>notebook.run</code></strong></a>([*, wait_for_finish=True])</td><td>Run a notebook.</td></tr><tr><td><a href="/pages/sIEaYTIgoYVb0gY4zHIz"><strong><code>notebook.referenced_tables</code></strong></a>()</td><td>Get an ordered list of tables referenced by the notebook.</td></tr><tr><td><a href="/pages/sIEaYTIgoYVb0gY4zHIz"><strong><code>notebook.source_table</code></strong></a>()</td><td>Get the notebook's source table.</td></tr><tr><td><a href="/pages/woARGUe5ottOOxBonhee"><strong><code>notebook.stop</code></strong></a>()</td><td>Stop a running notebook.</td></tr><tr><td><a href="/pages/JFm6rW9UQXCBaXCOT0tB"><strong><code>notebook.update</code></strong></a>([*, name, source_table])</td><td>Update the notebook's name and/or source.</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-python/reference/notebook.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.
