Skip to content

Start a session

Codespaces are an asset of a Use Case. They store notebooks and associated files. This page outlines how to start a codespace session, upload files to a codespace, and manage its contents. You can view and manage codespaces from the Notebooks tile of the Use Case home page.

Sharing

Although you cannot share individual codespaces directly with other users, in Workbench you can share Use Cases that contain codespaces. Therefore, to share a codespace with another user, you must share the entire Use Case so that they have access to all associated assets.

Review the capabilities overview and limits in the tabs below.

Review the table below to understand the functional differences between a codespace and a DataRobot Notebook.

Functionality DataRobot Notebook Codespace
Metadata (tags/description) Yes (at the notebook level) Yes (at the codespace level)
Git integration No Yes
Persistent file system No Yes
File editor No Yes
Terminal Yes Yes
Version control Yes (built-in revision history) Yes (controlled via external Git repos)
Environment variables Yes (at the notebook level) Yes (at the codespace level)
Session Yes (one container session per notebook) Yes (one container session per codespace)
Local IDE over SSH No Yes
Notebook scheduling Yes Yes

The following limits are in place for codespaces.

Limit Value
File system limits
Max upload size for an individual non-notebook file 1GB
Max size of each codespace file system 20GB
Session limits
Max number of codespaces per org (default) 50
Max number of active codespace notebook kernels used for .ipynb files 5
In-session limits
Max size for an individual notebook (.ipynb) file 25MB
Max number of open notebook files (in tabbed file editor) at the same time 5

Add a codespace

To get started creating a codespace:

  1. Navigate to the Use Case in which you want the codespace included and expand the Add dropdown. Hover on **Codespace and click:

    • Add codespace to create a new codespace and add files after creation.
    • Upload codespace to create the new codespace from local storage or a public or private repository.

Using the Add options create a new codespace. After selecting, click Start session. Codespace initialization begins.

You can upload a local folder with a collection of files or use a Git URL to create the codespace on DataRobot. When you click Upload DataRobot creates a new codespace, starts up the codespace session, and uploads the selected file(s) to the codespace file system.

You can also create a new codespace from an existing public Git repository. In the upload modal, specify the Git repository URL for the repo that you want to clone. When you click Upload, DataRobot creates a new codespace, starts up the codespace session, and clones the Git repository to the codespace file system. If you want to clone a private repo to a codespace, you must first create a new, empty codespace, then clone the repo using the Git CLI from the terminal. Integrating the Git provider with DataRobot allows DataRobot access to your repositories using the OAuth 2.0 standard.

Start a codespace session

To manage the contents of the codespace file system or edit and execute its files, you must first start the codespace's environment. Click the Session environment tile to configure the environment. The environment image determines the coding language, dependencies, and open-source libraries used in the notebook. The default image for a codespace is a pre-built Python image but you can also use a custom environment for the codespace session.

Once the environment is selected, you can choose a version ior use the default Latest. Then, start the container by toggling it on in the toolbar. Wait a moment for the environment to initialize, and once it displays the Started status, you can begin working with the codespace.

Note

The Python 3.11 version will be deprecated in a future relase.

Codespace environment variables

For codespace entities, environment variables are defined at the codespace level and not the individual notebook file level. When a codespace session is started, DataRobot sets all environment variables defined in the Environment Variables tab. You can retrieve these environment variables, via code, from any notebooks in the codespace file system.

To access environment variables, click the Environment variables tile in the sidebar. Then click Create new entry. In the dialog box, enter the key and value for a single entry; optionally provide a description.

To add multiple variables, select Bulk import from the entry dropdown. In the entry window, enter each variable, on a new line, in the following format:

KEY=VALUE # DESCRIPTION

Note

Any existing environment variable with the same key will have its value overwritten by the new value specified.

When you have finished adding environment variables, click Save.

Work with files

Each codespace consists of its own persistent file system, which is mounted to the path /home/notebooks/storage/ when the session begins. (You must start the codespace's environment before uploading files to it.) Click the Files tile in the left sideabar to upload and manage files and folders. You can also create new folders, notebook files, and non-notebook files from the file browser UI. To work with notebooks, upload .ipynbfiles.

Use the icons to:

  • Create a notebook, file, or directory.
  • Manage file content (copy, cut, paste, and delete).

Field Description
1 Create notebook Creates an executable .ipynb file. Provide a name for the notebook file.
2 Create file Creates a new file in the current folder of the codespace. Provide a name and specify the file type with an extension. After creating a file, it appears as part of the codespace folder.
3 Create directory Creates a folder within the current folder of the codespace. Provide a name for the folder.

Managed SaaS users only

For Managed SaaS AI Platform users, DataRobot provides backup functionality and retention policies for codespaces. DataRobot takes snapshots of the codespace volume on session shutdown and on codespace deletion and will retain the contents for 30 days if you need to restore the codespace data.

To manage or edit files from directly within a codespace, expand the Actions menu to the right of the file to view the available actions.

Work with notebooks in a codespace

To edit and execute a notebook within a codespace, double click on a notebook file (.ipynb) in the file browser to open it. The codespace interface supports a tabbed experience, so you can open, view, and edit multiple files at the same time. Similar to Jupyter, opening a notebook file will start a kernel process for that notebook. Each opened notebook will run in its own kernel.

DataRobot indicates which notebooks are running in active kernels with the purple notebook icon in the file browser. Inactive notebooks use a white icon.

To shut down a kernel, open the Actions menu for a notebook file and select Shut down kernel.

Work with non-notebook files

In addition to editing and executing notebooks, codespaces offer a text editor for you to also view and edit other file types. For example, as shown below, you can view image files and edit Python utility scripts.

Persistent dependency installations

When you install runtime custom dependencies into a codespace during an active session, Python and pip dependencies and HuggingFace artifacts can persist across sessions if they are installed to the user's virtual env. This persistent dependency installation capability is only supported when Python-based images are used for the codespace session.

A codespace has two virtual environments:

  • The user virtual environment,(/home/notebooks/storage/.venv): A new user virtual environment that persists any custom dependencies that are installed at runtime throughout codespace sessions. This venv is associated with the codespace (since it's persisted in the codespace file system), so all users who have access to the codespace will be able to access the same set of persisted pip installations when they start the codespace session.

  • The kernel virtual environment, (/etc/system/kernel/.venv): A built-in image virtual environment that holds all dependencies that DataRobot provides as a part of the selected notebook environment image. This virtual environment does not maintain any custom dependencies that you install; it maintains them for the duration of the session.

Although you cannot directly access the user virtual environment from the UI (it is not shown in the codespace file system panel), you can access it via the terminal. This is where you can install custom dependencies that will persist across sessions via !pip install <PACKAGE_NAME>.

By default, all new dependencies you install via !pip install will go into the user venv. The user venv takes precedence if you install a different version of a library DataRobot provides as a part of the built-in notebook image.

Disable persistent dependency installations

If you want to disable persistent dependency installation for a given codespace, first add a new environment variable NOTEBOOKS_NO_PERSISTENT_DEPENDENCIES=1 to the codespace. Then, run rm -rf /home/notebooks/storage/.venv from the codespace terminal to remove the existing user venv. After that, restart your codespace session. Any Python dependencies installed at runtime will no longer be persisted between sessions.

Dependency installation considerations

DataRobot packages

If you use the dependency installation feature to install the datarobotx package or newer versions of the datarobot package (newer than the version preinstalled in the built-in images), you can corrupt the preinstalled datarobot package included with other DataRobot packages (e.g., datarobot-mlops-connected-client). This is because when you install a new package or a new version of an existing package in an active codespace session, it’s installed into the user's virtual environment which takes precedence over the kernel virtual environment. Installing the datarobotx package creates the datarobot package in the user's virtual environment, preventing the correct installation in the kernel environment. This interferes with the successful installation of packages such as the datarobot-mlops-connected-client; however, pip (or your package manager of choice) still registers the package as installed.

To resolve this error, run pip install with --force-reinstall for all shadowed libraries extending the datarobot package (e.g., datarobot-mlops-connected-client). For example pip install datarobot-mlops-connected-client --force-reinstall.

Updating dependencies

After importing a dependency, you may upgrade it over time. Because DataRobot does not automatically recognize these dependency changes, you must restart the kernel in order for DataRobot to recognize the changes. To do so, click the restart icon (the circular arrow) in the toolbar.

Check import locations

To check where a dependency was imported from, run the following command in a notebook cell or in the terminal.

pip list -v
Package                          Version      Location                                             Installer
-------------------------------- ------------ ---------------------------------------------------- ---------
...
datarobot                        3.3.0        /etc/system/kernel/.venv/lib/python3.9/site-packages pip
...

To check the size of a user virtual environment, run the following command in the terminal.

(.venv) [notebooks@kernel ~/storage]$ du -h . -d 1
14M     ./.venv
14M     .

If your user virtual environment seems broken and you want to recreate it, run the following command in the terminal.

rm -rf /home/notebooks/storage/.venv
python -m venv /home/notebooks/storage/.venv

Next steps

With a codespace session running, automate notebook runs on a schedule or use the integrated terminal to manage your environment further.