snowflake.core.notebook.NotebookResource | Snowflake Documentation (original) (raw)

class snowflake.core.notebook.NotebookResource(name: str, collection: NotebookCollection)

Bases: SchemaObjectReferenceMixin[NotebookCollection]

Represents a reference to a Snowflake notebook.

With this notebook reference, you can fetch information about notebooks, as well as perform certain actions on them: renaming, executing, committing, and managing versions.

Attributes

database

The DatabaseResource this reference belongs to.

fully_qualified_name

Return the fully qualified name of the object this reference points to.

root

The Root object this reference belongs to.

Methods

add_live_version(from_last: bool | None = None, comment: str | None = None) → None

Add a LIVE version to the notebook.

The LIVE version is the version that runs when the notebook is executed.

Parameters:

Examples

Adding a LIVE version to this notebook using its reference:

notebook_reference.add_live_version(from_last=True, ... comment="new live version")

add_live_version_async(from_last: bool | None = None, comment: str | None = None) → PollingOperation[None]

An asynchronous version of add_live_version().

Refer to PollingOperation for more information on asynchronous execution and the return type.

commit(version: str | None = None, comment: str | None = None) → None

Commit the LIVE version of the notebook to the Git.

If a Git connection is set up for the notebook, commits the LIVE version of the notebook to the Git repository.

If no Git repository is set up for the notebook, running this command sets the LIVE version to null and increments the auto-generated version alias.

Parameters:

Examples

Committing a notebook using its reference:

notebook_reference.commit(version="prod-1.1.0", ... comment="prod release 1.1.0")

commit_async(version: str | None = None, comment: str | None = None) → PollingOperation[None]

An asynchronous version of commit().

Refer to PollingOperation for more information on asynchronous execution and the return type.

drop(if_exists: bool = False) → None

Drop this notebook.

Parameters:

if_exists (bool , optional) – If True, does not throw an exception if the notebook does not exist. The default is False.

Examples

Deleting a notebook using its reference:

notebook_reference.drop()

Using a notebook reference to delete a notebook if it exists:

notebook_reference.drop(if_exists=True)

drop_async(if_exists: bool = False) → PollingOperation[None]

An asynchronous version of drop().

Refer to PollingOperation for more information on asynchronous execution and the return type.

execute() → None

Execute this notebook.

Examples

Executing a notebook using its reference:

notebook_reference.execute()

execute_async() → PollingOperation[None]

An asynchronous version of execute().

Refer to PollingOperation for more information on asynchronous execution and the return type.

fetch() → Notebook

Fetch the details of a notebook resource.

Examples

Fetching a notebook using its reference:

notebook = notebook_reference.fetch() print(notebook.name, notebook.comment)

fetch_async() → PollingOperation[Notebook]

An asynchronous version of fetch().

Refer to PollingOperation for more information on asynchronous execution and the return type.

rename(target_name: str, target_database: str | None = None, target_schema: str | None = None, if_exists: bool | None = None) → None

Rename this notebook.

Parameters:

Examples

Renaming this notebook using its reference:

notebook_reference.rename("my_other_notebook")

Renaming this notebook if it exists:

notebook_reference.rename("my_other_notebook", if_exists = True)

rename_async(target_name: str, target_database: str | None = None, target_schema: str | None = None, if_exists: bool | None = None) → PollingOperation[None]

An asynchronous version of rename().

Refer to PollingOperation for more information on asynchronous execution and the return type.