Skip to content

Notebooks

NotebookType

class datarobot.models.notebooks.enums.NotebookType

Types of notebooks.

RunType

class datarobot.models.notebooks.enums.RunType

Types of notebook job runs.

ManualRunType

class datarobot.models.notebooks.enums.ManualRunType

A subset of RunType To be used in API schemas.

SessionType

class datarobot.models.notebooks.enums.SessionType

Types of notebook sessions. Triggered sessions include notebook job runs whether manually triggered or scheduled.

ScheduleStatus

class datarobot.models.notebooks.enums.ScheduleStatus

Possible statuses for notebook schedules.

ScheduledRunStatus

class datarobot.models.notebooks.enums.ScheduledRunStatus

Possible statuses for scheduled notebook runs.

NotebookPermissions

class datarobot.models.notebooks.enums.NotebookPermissions

Permissions for notebooks.

NotebookStatus

class datarobot.models.notebooks.enums.NotebookStatus

Possible statuses for notebook sessions.

KernelExecutionStatus

class datarobot.models.notebooks.enums.KernelExecutionStatus

Possible statuses for kernel execution.

CellType

class datarobot.models.notebooks.enums.CellType

Types of cells in a notebook.

RuntimeLanguage

class datarobot.models.notebooks.enums.RuntimeLanguage

Languages as used in notebook jupyter kernels.

ImageLanguage

class datarobot.models.notebooks.enums.ImageLanguage

Languages as used and supported in notebook images.

KernelSpec

class datarobot.models.notebooks.enums.KernelSpec

Kernel specifications for Jupyter notebook kernels.

KernelState

class datarobot.models.notebooks.enums.KernelState

Possible states for notebook kernels.

exception datarobot.models.notebooks.exceptions.KernelNotAssignedError

Raised when a Codespace notebook does not have a kernel assigned.

ManualRunPayload

class datarobot.models.notebooks.notebook.ManualRunPayload

Notebook

class datarobot.models.notebooks.notebook.Notebook

Metadata for a DataRobot Notebook accessible to the user.

Variables

Attribute Type Description
id str The ID of the Notebook.
name str The name of the Notebook.
type NotebookType The type of the Notebook. Can be “plain” or “codespace”.
permissions List[NotebookPermissions] The permissions the user has for the Notebook.
tags List[str] Any tags that have been added to the Notebook. Default is an empty list.
created NotebookActivity Information on when the Notebook was created and who created it.
updated NotebookActivity Information on when the Notebook was updated and who updated it.
last_viewed NotebookActivity Information on when the Notebook was last viewed and who viewed it.
settings NotebookSettings Information on global settings applied to the Notebook.
org_id Optional[str] The organization ID associated with the Notebook.
tenant_id Optional[str] The tenant ID associated with the Notebook.
description Optional[str] The description of the Notebook. Optional.
session Optional[NotebookSession] Metadata on the current status of the Notebook and its kernel. Optional.
use_case_id Optional[str] The ID of the Use Case the Notebook is associated with. Optional.
use_case_name Optional[str] The name of the Use Case the Notebook is associated with. Optional.
has_schedule bool Whether or not the notebook has a schedule.
has_enabled_schedule bool Whether or not the notebook has a currently enabled schedule.

get_uri()

method get_uri()

Returns

Returns Description
url Permanent static hyperlink to this Notebook in its Use Case or standalone.

Return type: str

get()

classmethod get()

Retrieve a single notebook.

Parameters

Parameter Type Description
notebook_id str The ID of the notebook you want to retrieve.

Returns

Returns Description
notebook The requested notebook.

Return type: Notebook

Examples

from datarobot.models.notebooks import Notebook

notebook = Notebook.get(notebook_id='6556b00dcc4ea0bb7ea48121')

create_revision()

method create_revision()

Create a new revision for the notebook.

Parameters

Parameter Type Description
name Optional[str] The name of the revision. Optional.
notebook_path Optional[str] The path of the notebook to execute within the codespace. Required if notebook is in a codespace.
is_auto bool Indicates whether the revision was auto-saved versus a user interaction. Default is False.

Returns

Returns Description
notebook_revision Information about the created notebook revision.

Return type: NotebookRevision

download_revision()

method download_revision()

Downloads the notebook as a JSON (.ipynb) file for the specified revision.

Parameters

Parameter Type Description
file_path string, optional The destination to write the file to.
filelike file, optional A file-like object to write to. The object must be able to write bytes. The user is responsible for closing the object.

Return type: None

Examples

from datarobot.models.notebooks import Notebook

notebook = Notebook.get(notebook_id='6556b00dcc4ea0bb7ea48121')
manual_run = notebook.run_as_job()
revision_id = manual_run.wait_for_completion()
notebook.download_revision(revision_id=revision_id, file_path="./results.ipynb")

delete()

method delete()

Delete a single notebook

Examples

from datarobot.models.notebooks import Notebook

notebook = Notebook.get(notebook_id='6556b00dcc4ea0bb7ea48121')
notebook.delete()

Return type: None

list()

classmethod list()

List all Notebooks available to the user.

Parameters

Parameter Type Description
created_before Optional[str] List Notebooks created before a certain date. Optional.
created_after Optional[str] List Notebooks created after a certain date. Optional.
order_by Optional[str] Property to sort returned Notebooks. Optional. Supported properties are “name”, “created”, “updated”, “tags”, and “lastViewed”. Prefix the attribute name with a dash to sort in descending order, e.g., order_by=’-created’. By default, the order_by parameter is None.
tags Optional[List[str]] A list of tags that returned Notebooks should be associated with. Optional.
owners Optional[List[str]] A list of user IDs used to filter returned Notebooks. The respective users share ownership of the Notebooks. Optional.
query Optional[str] A specific regex query to use when filtering Notebooks. Optional.
use_cases Optional[UseCase or List[UseCase] or str or List[str]] Filters returned Notebooks by a specific Use Case or Cases. Accepts either the entity or the ID. Optional. If set to [None], the method filters the notebook’s datasets by those not linked to a UseCase.

Returns

Returns Description
notebooks A list of Notebooks available to the user.

Return type: List[Notebook]

Examples

from datarobot.models.notebooks import Notebook

notebooks = Notebook.list()

is_running()

method is_running()

Check if the notebook session is currently running.

Return type: bool

get_session_status()

method get_session_status()

Get the status of the notebook session.

Return type: NotebookStatus

start_session()

method start_session()

Start a new session for the notebook.

Parameters

Parameter Type Description
is_triggered_run bool Whether the session being started is considered an “interactive” or “triggered” session. Default is False.
parameters Optional[List[StartSessionParameters]] A list of dictionaries in the format {“name”: “FOO”, “value”: “my_value”} representing environment variables propagated to the notebook session.
open_file_paths Optional[List[str]] A list of file paths to open upon instantiation of the notebook session.
clone_repository Optional[CloneRepositorySchema] Information used to clone a remote repository as part of the environment setup flow.

Returns

Returns Description
notebook_session The created notebook session.

Return type: NotebookSession

Examples

from datarobot.models.notebooks import Notebook

notebook = Notebook.get(notebook_id='6556b00dcc4ea0bb7ea48121')
session = notebook.start_session()

stop_session()

method stop_session()

Stop the current session for the notebook.

Returns

Returns Description
notebook_session The stopped notebook session.

Return type: NotebookSession

Examples

from datarobot.models.notebooks import Notebook

notebook = Notebook.get(notebook_id='6556b00dcc4ea0bb7ea48121')
session = notebook.stop_session()

execute()

method execute()

Execute the notebook. Assumes session is already started.

Parameters

Parameter Type Description
notebook_path Optional[str] The path of the notebook to execute within the Codespace. Required if the notebook is in a Codespace.
cell_ids Optional[List[str]] The list of cell IDs to execute for a notebook. Not supported if the notebook is in a Codespace. Optional. If not provided, the whole notebook will be executed.

Return type: None

get_execution_status()

method get_execution_status()

Get the execution status information of the notebook.

Returns

Returns Description
execution_status The notebook execution status information.

Return type: NotebookExecutionStatus

is_finished_executing()

method is_finished_executing()

Check if the notebook is finished executing.

Parameters

Parameter Type Description
notebook_path Optional[str] The path of the notebook the Codespace. Required only if the notebook is in a Codespace. Will raise an error if working with a standalone notebook.

Returns

Returns Description
is_finished_executing Whether or not the notebook has finished executing.

Return type: bool

Raises

Exception Description
InvalidUsageError If attempting to check if a standalone notebook has finished executing and incorrectly passing a notebook path. If attempting to check if a codespace notebook has finished executing without passing a notebook path.
KernelNotAssignedError If attempting to check if a codespace notebook has finished executing but the notebook does not have a kernel assigned.

run_as_job()

method run_as_job()

Create a manual scheduled job that runs the notebook.

Notes

The notebook must be part of a Use Case. If the notebook is in a Codespace then notebook_path is required.

Parameters

Parameter Type Description
title Optional[str] The title of the background job. Optional.
notebook_path Optional[str] The path of the notebook to execute within the Codespace. Required if notebook is in a Codespace.
parameters Optional[List[StartSessionParameters]] A list of dictionaries in the format {“name”: “FOO”, “value”: “my_value”} representing environment variables predefined in the notebook session. Optional.
manual_run_type Optional[ManualRunType] The type of manual run being triggered. Defaults to “manual” as opposed to “pipeline”.

Returns

Returns Description
notebook_scheduled_job The created notebook schedule job.

Return type: NotebookScheduledJob

Raises

Exception Description
InvalidUsageError If attempting to create a manual scheduled run for a Codespace without a notebook path.

Examples

from datarobot.models.notebooks import Notebook

notebook = Notebook.get(notebook_id='6556b00dcc4ea0bb7ea48121')
manual_run = notebook.run_as_job()

# Alternatively, with title and parameters:
# manual_run = notebook.run_as_job(title="My Run", parameters=[{"name": "FOO", "value": "bar"}])

revision_id = manual_run.wait_for_completion()

list_schedules()

method list_schedules()

List all NotebookScheduledJobs associated with the notebook.

Parameters

Parameter Type Description
enabled_only bool Whether or not to return only enabled schedules.

Returns

Returns Description
notebook_schedules A list of schedules for the notebook.

Return type: List[NotebookScheduledJob]

Raises

Exception Description
InvalidUsageError If attempting to list schedules for a notebook not associated with a Use Case.

Examples

from datarobot.models.notebooks import Notebook

notebook = Notebook.get(notebook_id='6556b00dcc4ea0bb7ea48121')
enabled_schedules = notebook.list_schedules(enabled_only=True)

ExecutionEnvironmentAssignPayload

class datarobot.models.notebooks.execution_environment.ExecutionEnvironmentAssignPayload

Payload for assigning an execution environment to a notebook.

Image

class datarobot.models.notebooks.execution_environment.Image

Execution environment image information.

Variables

Attribute Type Description
id str The ID of the image.
name str The name of the image.
default bool Whether the image is the default image.
description str The description of the image.
environment_id str The ID of the environment.
gpu_optimized bool Whether the image is GPU optimized.
language ImageLanguage The runtime language of the image. For example “Python” or “R”
language_version str The version of the language. For example “3.11” or “4.3”
libraries list[str] A list of pre-installed libraries on the image.

Machine

class datarobot.models.notebooks.execution_environment.Machine

Execution environment machine information.

Variables

Attribute Type Description
id str The ID of the machine.
name str The name of the machine. Values include “XS”, “S”, “M”, “L” etc.
default bool Whether the machine is the default machine.
cpu str The CPU of the machine. For example a value like “2000m”.
cpu_cores int The number of CPU cores.
ephemeral_storage str The ephemeral storage of the machine. For example a value like “15Gi”.
has_gpu bool Whether the machine has a GPU.
memory str The memory of the machine. For example a value like “8Gi”.
ram_gb int The amount of RAM of the machine.

ExecutionEnvironment

class datarobot.models.notebooks.execution_environment.ExecutionEnvironment

An execution environment associated with a notebook.

Variables

Attribute Type Description
image Image The image associated with the execution environment.
machine Machine The machine associated with the execution environment.
time_to_live int The inactivity timeout for notebook session.

get()

classmethod get()

Get a notebook execution environment by its notebook ID.

Parameters

Parameter Type Description
notebook_id str The ID of the notebook.

Returns

Returns Description
The notebook execution environment.

Return type: ExecutionEnvironment

assign_environment()

classmethod assign_environment()

Assign execution environment values to a notebook.

Parameters

Parameter Type Description
notebook_id str The ID of the notebook.
payload ExecutionEnvironmentAssignPayload The payload for the assignment/update.

Returns

Returns Description
The assigned execution environment.

Return type: ExecutionEnvironment

Examples

from datarobot.models.notebooks import ExecutionEnvironment, ExecutionEnvironmentAssignPayload

payload = ExecutionEnvironmentAssignPayload(machine_slug='medium', time_to_live=10)
exec_env = ExecutionEnvironment.assign_environment('67914bfab0279fd832dc3fd1', payload)

NotebookKernel

class datarobot.models.notebooks.kernel.NotebookKernel

A kernel associated with a codespace notebook.

Variables

Attribute Type Description
id str The kernel ID.
name str The kernel name.
language RuntimeLanguage The kernel language. Supports Python and R.
running bool Whether the kernel is running.
execution_state KernelState The kernel execution state.

CreateRevisionPayload

class datarobot.models.notebooks.revision.CreateRevisionPayload

Payload for creating a notebook revision.

NotebookRevision

class datarobot.models.notebooks.revision.NotebookRevision

Represents a notebook revision.

Variables

Attribute Type Description
revision_id str The ID of the notebook revision.
notebook_id str The ID of the notebook.
is_auto bool Whether the revision was auto-saved.

create()

classmethod create()

Create a new notebook revision.

Parameters

Parameter Type Description
notebook_id str The ID of the notebook.
payload CreateRevisionPayload The payload to create the revision.

Returns

Returns Description
Information about the created notebook revision.

Return type: NotebookRevision

NotebookScheduledJob

class datarobot.models.notebooks.scheduled_job.NotebookScheduledJob

DataRobot Notebook Schedule. A scheduled job that runs a notebook.

Variables

Attribute Type Description
id str The ID of the scheduled notebook job.
enabled bool Whether job is enabled or not.
run_type RunType The type of the run - either manual (triggered via UI or API) or scheduled.
notebook_type NotebookType The type of the notebook - either plain or codespace.
job_payload ScheduledJobPayload The payload used for the background job.
next_run_time Optional[str] The next time the job is scheduled to run (assuming it is enabled).
title Optional[str] The title of the job. Optional.
schedule Optional[str] Cron-like string to define how frequently job should be run. Optional.
schedule_localized Optional[str] A human-readable localized version of the schedule. Example in English is ‘At 42 minutes past the hour’. Optional.
last_successful_run Optional[str] The last time the job was run successfully. Optional.
last_failed_run Optional[str] The last time the job failed. Optional.
last_run_time Optional[str] The last time the job was run (failed or successful). Optional.

get()

classmethod get()

Retrieve a single notebook schedule.

Parameters

Parameter Type Description
scheduled_job_id str The ID of the notebook schedule you want to retrieve.

Returns

Returns Description
notebook_schedule The requested notebook schedule.

Return type: NotebookScheduledJob

Examples

from datarobot.models.notebooks import NotebookScheduledJob

notebook_schedule = NotebookScheduledJob.get(
    use_case_id="654ad653c6c1e889e8eab12e",
    scheduled_job_id="65734fe637157200e28bf688",
)

list()

classmethod list()

List all NotebookScheduledJobs available to the user.

Parameters

Parameter Type Description
notebook_ids Optional[List[str]] Notebook IDs to filter listed schedules by. Optional.
statuses Optional[List[ScheduleStatus]] Statuses to filter listed schedules by. Includes values “disabled” and “enabled”. Optional.

Returns

Returns Description
notebook_schedules A list of NotebookScheduledJobs available to the user.

Return type: List[NotebookScheduledJob]

cancel()

method cancel()

Cancel a running notebook schedule.

Return type: None

get_most_recent_run()

method get_most_recent_run()

Retrieve the most recent run for the notebook schedule.

Returns

Returns Description
notebook_scheduled_run The most recent run for the notebook schedule, or None if no runs have been made.

Return type: Optional[NotebookScheduledRun]

Examples

from datarobot.models.notebooks import NotebookScheduledJob

notebook_schedule = NotebookScheduledJob.get(
    use_case_id="654ad653c6c1e889e8eab12e",
    scheduled_job_id="65734fe637157200e28bf688",
)
most_recent_run = notebook_schedule.get_most_recent_run()

get_job_history()

method get_job_history()

Retrieve list of historical runs for the notebook schedule. Gets the most recent runs first.

Returns

Returns Description
notebook_scheduled_runs The list of historical runs for the notebook schedule.

Return type: List[NotebookScheduledRun]

Examples

from datarobot.models.notebooks import NotebookScheduledJob

notebook_schedule = NotebookScheduledJob.get(
    use_case_id="654ad653c6c1e889e8eab12e",
    scheduled_job_id="65734fe637157200e28bf688",
)
notebook_scheduled_runs = notebook_schedule.get_job_history()

wait_for_completion()

method wait_for_completion()

Wait for the completion of a scheduled notebook and return the revision ID corresponding to the run’s output.

Parameters

Parameter Type Description
max_wait int The number of seconds to wait before giving up.

Returns

Returns Description
revision_id Returns either revision ID or message describing current state.

Return type: str

Examples

from datarobot.models.notebooks.notebook import Notebook

notebook = Notebook.get(notebook_id='6556b00dcc4ea0bb7ea48121')
manual_run = notebook.run_as_job()
revision_id = manual_run.wait_for_completion()

ScheduledJobParam

class datarobot.models.notebooks.scheduled_run.ScheduledJobParam

DataRobot Schedule Job Parameter.

Variables

Attribute Type Description
name str The name of the parameter.
value str The value of the parameter.

ScheduledJobPayload

class datarobot.models.notebooks.scheduled_run.ScheduledJobPayload

DataRobot Schedule Job Payload.

Variables

Attribute Type Description
uid str The ID of the user who created the notebook schedule.
org_id str The ID of the user’s organization who created the notebook schedule.
use_case_id str The ID of the Use Case that the notebook belongs to.
notebook_id str The ID of the notebook being run on a schedule.
notebook_name str The name of the notebook being run on a schedule.
run_type RunType The type of the run - either manual (triggered via UI or API) or scheduled.
notebook_type NotebookType The type of the notebook - either plain or codespace.
parameters List[ScheduledJobParam] The parameters being used in the notebook schedule. Can be an empty list.
notebook_path Optional[str] The path of the notebook to execute within the codespace. Optional. Required if notebook is in a codespace.
use_case_name Optional[str] The name of the Use Case that the notebook belongs to.

ScheduledRunRevisionMetadata

class datarobot.models.notebooks.scheduled_run.ScheduledRunRevisionMetadata

DataRobot Notebook Revision Metadata specifically for a scheduled run.

Both id and name can be null if for example the job is still running or has failed.

Variables

Attribute Type Description
id Optional[str] The ID of the Notebook Revision. Optional.
name Optional[str] The name of the Notebook Revision. Optional.

NotebookScheduledRun

class datarobot.models.notebooks.scheduled_run.NotebookScheduledRun

DataRobot Notebook Scheduled Run. A historical run of a notebook schedule.

Variables

Attribute Type Description
id str The ID of the scheduled notebook job.
use_case_id str The Use Case ID of the scheduled notebook job.
status str The status of the run.
payload ScheduledJobPayload The payload used for the background job.
title Optional[str] The title of the job. Optional.
start_time Optional[str] The start time of the job. Optional.
end_time Optional[str] The end time of the job. Optional.
revision ScheduledRunRevisionMetadata Notebook revision data - ID and name.
duration Optional[int] The job duration in seconds. May be None for example while the job is running. Optional.
run_type Optional[RunType] The type of the run - either manual (triggered via UI or API) or scheduled. Optional.
notebook_type Optional[NotebookType] The type of the notebook - either plain or codespace. Optional.

CloneRepositorySchema

class datarobot.models.notebooks.session.CloneRepositorySchema

Schema for cloning a repository when starting a notebook session.

StartSessionParameters

class datarobot.models.notebooks.session.StartSessionParameters

Parameters used as environment variables in a notebook session.

StartSessionPayload

class datarobot.models.notebooks.session.StartSessionPayload

Payload for starting a notebook session.

NotebookExecutionStatus

class datarobot.models.notebooks.session.NotebookExecutionStatus

Notebook execution status information.

Variables

Attribute Type Description
status str The status of the notebook execution.
cell_id Optional[bson.ObjectId] The ID of the cell being executed. Optional.
queued_cell_ids Optional[List[bson.ObjectId]] The list of cell IDs that are queued for execution. Optional.

CodespaceNotebookCell

class datarobot.models.notebooks.session.CodespaceNotebookCell

Represents a cell in a codespace notebook.

CodespaceNotebookState

class datarobot.models.notebooks.session.CodespaceNotebookState

Notebook state information for a codespace notebook.

Variables

Attribute Type Description
name str The name of the notebook.
path str The path of the notebook.
generation int The generation of the notebook.
nbformat int The notebook format version.
nbformat_minor int The notebook format minor version.
metadata dict The metadata of the notebook.
cells List[CodespaceNotebookCell] The list of cells in the notebook.
kernel_id Optional[str] The ID of the kernel. Optional.

NotebookSession

class datarobot.models.notebooks.session.NotebookSession

Notebook session information.

Variables

Attribute Type Description
status NotebookStatus The current status of the notebook kernel.
notebook_id str The ID of the notebook.
session_id str The ID of the session. Incorporates the notebook_id as part of this ID.
started_at Optional[str] The date and time when the notebook was started. Optional.
session_type Optional[SessionType] The type of the run - either manual (triggered via UI or API) or scheduled. Optional.
ephemeral_session_key Optional[str] The ID specific to ephemeral session if being used. Optional.

get()

classmethod get()

Get a notebook session by its notebook ID.

Parameters

Parameter Type Description
notebook_id str The ID of the notebook.

Returns

Returns Description
The notebook session information.

Return type: NotebookSession

start()

classmethod start()

Start a notebook session.

Parameters

Parameter Type Description
notebook_id str The ID of the notebook.
payload StartSessionPayload The payload to start the session.

Returns

Returns Description
The notebook session information.

Return type: NotebookSession

stop()

classmethod stop()

Stop a notebook session.

Parameters

Parameter Type Description
notebook_id str The ID of the notebook.

Returns

Returns Description
The notebook session information.

Return type: NotebookSession

execute_notebook()

classmethod execute_notebook()

Execute a notebook.

Parameters

Parameter Type Description
notebook_id str The ID of the notebook.
cell_ids Optional[List[bson.ObjectId]] The list of cell IDs to execute. Optional. If not provided, the whole notebook will be executed.

Return type: None

execute_codespace_notebook()

classmethod execute_codespace_notebook()

Execute a notebook.

Parameters

Parameter Type Description
notebook_id str The ID of the notebook.
notebook_path str The path of the notebook.
generation int The generation of the notebook.
cells List[CodespaceNotebookCell] The list of cells to execute.

Return type: None

get_execution_status()

classmethod get_execution_status()

Get the execution status information of a notebook.

Parameters

Parameter Type Description
notebook_id str The ID of the notebook.

Returns

Returns Description
The execution status information of the notebook.

Return type: NotebookExecutionStatus

NotebookSettings

class datarobot.models.notebooks.settings.NotebookSettings

Settings for a DataRobot Notebook.

Variables

Attribute Type Description
show_line_numbers bool Whether line numbers in cells should be displayed.
hide_cell_titles bool Whether cell titles should be displayed.
hide_cell_outputs bool Whether the cell outputs should be displayed.
show_scrollers bool Whether scroll bars should be shown on cells.
hide_cell_footers bool Whether footers should be shown on cells.
highlight_whitespace bool Whether whitespace should be highlighted or not.

NotebookUser

class datarobot.models.notebooks.user.NotebookUser

A user associated with a Notebook.

Variables

Attribute Type Description
id str The ID of the user.
activated bool Whether or not the user is enabled.
username str The username of the user, usually their email address.
first_name str The first name of the user.
last_name str The last name of the user.
gravatar_hash Optional[str] The gravatar hash of the user. Optional.
tenant_phase Optional[str] The phase that the user’s tenant is in. Optional.

NotebookActivity

class datarobot.models.notebooks.user.NotebookActivity

A record of activity (i.e., last run, updated, etc.) in a Notebook.

Variables

Attribute Type Description
at str The time of the activity in the notebook.
by NotebookUser The user who performed the activity.