---
title: Shared Serverless
description: Use Shared Serverless to share compute and a Python environment for notebooks and files in Git folders and bundles.
canonical_url: https://docs.databricks.com/gcp/en/compute/serverless/notebooks/shared-serverless
---

# <a id="shared-serverless" />Shared Serverless

> [!NOTE]
> **Beta**
>
> This feature is in [Beta](https://docs.databricks.com/gcp/en/release-notes/release-types.md). To use it, a workspace admin must turn on **Project-Scoped Shared Compute** from the **Previews** page. See [Manage Databricks previews](https://docs.databricks.com/gcp/en/admin/workspace-settings/manage-previews.md).

With Shared Serverless, notebooks and files in the same Git folder or bundle share serverless compute and a Python environment in the editor. To customize the environment, add a `pyproject.toml` file at the folder root. To attach a notebook or file, follow the steps for [Git folders](https://docs.databricks.com/gcp/en/compute/serverless/notebooks/shared-serverless.md#git-folder-serverless) or [Declarative Automation Bundles](https://docs.databricks.com/gcp/en/compute/serverless/notebooks/shared-serverless.md#asset-bundles-serverless).

## <a id="requirements" />Requirements

* Your workspace must meet the [serverless compute requirements](https://docs.databricks.com/gcp/en/compute/serverless/index.md#requirements).
* Open your Git folder or bundle in the Git folder editor or the bundle editor. See [Create and manage Git folders](https://docs.databricks.com/gcp/en/repos/git-operations-with-repos.md) and [Author bundles in the workspace](https://docs.databricks.com/gcp/en/dev-tools/bundles/workspace-author.md).
* Shared Serverless requires serverless environment version 5 or above.

## <a id="shared-compute-and-environment" />Shared compute and environment

* Notebooks and files in the same Git folder or bundle share compute and a Python environment in the editor. An optional `pyproject.toml` file at the folder root defines the shared environment.
* Only notebooks and files inside the associated Git folder or bundle can attach to its shared compute resource.
* Each shared compute resource belongs to the user who first attaches a notebook or file to it. Only that user can run workloads on it. Other users in the same Git folder or bundle can't run notebooks or files on that compute resource. See [Collaborate through Git](https://docs.databricks.com/gcp/en/compute/serverless/notebooks/shared-serverless.md#collaborate-through-git).
* Notebook execution remains isolated. Python variables defined in one notebook are not available in another notebook.
* A [web terminal](https://docs.databricks.com/gcp/en/compute/web-terminal.md) opened from an attached notebook or file runs on the same compute resource.

## <a id="git-folder-serverless" />Use Shared Serverless in Git folders

Use Shared Serverless to work with notebooks and files in a [Git folder](https://docs.databricks.com/gcp/en/repos/index.md).

### <a id="use-git-folder-serverless-in-the-git-folder-editor" />Attach notebooks and files in the Git folder editor

1. In the workspace sidebar, click **Workspace** and navigate to the Git folder.

2. Click **Open in editor**.

3. Open a notebook or file in the Git folder.

4. Click the compute drop-down menu.

5. Select **Shared Serverless**.

   ![Compute drop-down option for shared serverless compute, with a Beta badge and an environment from pyproject.toml](https://docs.databricks.com/gcp/en/images/serverless-compute/git-folder-serverless-compute-selector.png)

6. Run the notebook or file to start the compute resource.

To use the same compute from another notebook or file, open it in the same Git folder and select **Shared Serverless**.

### <a id="collaborate-through-git" />Collaborate through Git

Databricks recommends that each collaborator [clone the repository](https://docs.databricks.com/gcp/en/repos/git-operations-with-repos.md#clone-repo) into a Git folder in their personal workspace folder. Each collaborator then gets a separate compute resource and environment for their clone.

Use branches, commits, pushes, and pulls to exchange changes through the remote Git repository. See [Collaborate in Git folders](https://docs.databricks.com/gcp/en/repos/git-operations-with-repos.md#best-practices).

If you run a notebook or file attached to another user's shared compute resource, the run fails with the following error:

```text
User does not have permission to run on existing session
```

To run the notebook or file, use your own clone. Or, in the compute drop-down menu, click **Terminate**, and then select **Shared Serverless** again to start your own compute resource. Terminating the compute resource ends the other user's session, and they lose their Python state.

## <a id="asset-bundles-serverless" />Use Shared Serverless in bundles

Use Shared Serverless to work with notebooks and files in a [bundle in the workspace](https://docs.databricks.com/gcp/en/dev-tools/bundles/workspace-author.md). The bundle root contains `databricks.yml` and can contain a `pyproject.toml` file that defines the shared environment.

### <a id="attach-in-bundle-editor" />Attach notebooks and files in the bundle editor

1. In the workspace sidebar, click **Workspace** and navigate to the bundle.
2. To the right of the bundle name, click **Open in editor**.
3. Open a notebook or file in the bundle.
4. Click the compute drop-down menu.
5. Select **Shared Serverless**.
6. Run the notebook or file to start the compute resource.

To use the same compute from another notebook or file, open it in the same bundle and select **Shared Serverless**.

To collaborate through Git, have each collaborator clone the repository into a Git folder in their personal workspace folder. See [Collaborate through Git](https://docs.databricks.com/gcp/en/compute/serverless/notebooks/shared-serverless.md#collaborate-through-git).

## <a id="project-environment" />Manage the environment with `pyproject.toml`

Shared Serverless uses the `pyproject.toml` file at the Git folder or bundle root to manage Python dependencies for the project. Standard serverless notebooks use dependencies configured for each notebook in the **Environment** side pane.

Create the root `pyproject.toml` file and set its serverless environment version before managing its dependencies. See [Create and edit `pyproject.toml`](https://docs.databricks.com/gcp/en/compute/serverless/notebooks/shared-serverless.md#edit-pyprojecttoml). You can then add dependencies with notebook commands or edit the file directly.

### <a id="use-notebook-commands" />Use notebook commands

1. Open a notebook attached to Shared Serverless.
2. Run `%uv add <package>` to add a dependency to the root `pyproject.toml` file. For example:

   ```python
   %uv add cowsay
   ```

The command updates `pyproject.toml`, `uv.lock`, and the shared environment. You do not need to run `%uv sync` after `%uv add`. Use `%uv sync` to apply changes made directly to `pyproject.toml`.

### <a id="edit-pyprojecttoml" />Create and edit `pyproject.toml`

1. Open a notebook attached to Shared Serverless.

2. Open the **Environment** side pane.

3. In the **Managed by pyproject.toml** card, click ![File new icon.](https://docs.databricks.com/gcp/en/images/product-icons/FileNewIcon.svg) **Create pyproject.toml** to create the root file. If the file already exists, click ![New window icon.](https://docs.databricks.com/gcp/en/images/product-icons/NewWindowIcon.svg) **View pyproject.toml**. The file opens in the editor.

   ![Environment side pane with the Create pyproject.toml icon and tooltip beside Managed by pyproject.toml.](https://docs.databricks.com/gcp/en/images/serverless-compute/create-project-pyproject.png)

4. Edit the `dependencies` list. Keep the generated `[tool.databricks.environment]` section, or add it if missing. Set `environment_version` to a supported version (5 and above). For example:

   ```toml
   [project]
   name = "my-project"
   version = "0.1.0"
   dependencies = [
     "simplejson==3.18.1",
   ]

   [tool.databricks.environment]
   environment_version = "5"
   ```

5. Click **Apply** at the top of the `pyproject.toml` file editor.

   ![The pyproject.toml file editor showing the Apply button and its tooltip.](https://docs.databricks.com/gcp/en/images/serverless-compute/apply-project-pyproject.png)

The updated environment is available to notebooks and files attached to the same shared compute resource. To inspect the environment, open the **Environment** side pane. See [Configure the serverless environment](https://docs.databricks.com/gcp/en/compute/serverless/dependencies.md) for information about serverless environment versions and installed dependencies.

## <a id="schedule-job" />Schedule a notebook

When you schedule a notebook attached to Shared Serverless from the Git folder or bundle editor, Databricks uses the root `pyproject.toml` file as the job's project environment if the file exists. Deploy the bundle as described in the following steps.

1. In the Git folder or bundle editor, open a notebook attached to Shared Serverless.
2. If the Git folder or bundle has a root `pyproject.toml` file, verify that it declares the dependencies needed by the task.
3. Click **Schedule**.
4. In the **Compute** drop-down list, select serverless compute.
5. Configure the schedule and click **Create**.

After you click **Create**, check the job configuration:

* **Git folder:** If the Git folder has a root `pyproject.toml` file, verify that **Project environment** in the job's task configuration points to it. To change the selection, see [Configure environment for job tasks](https://docs.databricks.com/gcp/en/compute/serverless/dependencies.md#libraries).
* **Bundle:** The bundle editor opens a generated job YAML file in the `resources/` folder.

  1. If the bundle has a root `pyproject.toml` file, verify that `project_environment` under the environment's `spec` points to it, relative to the generated YAML file. See [Configure a project environment in a bundle](https://docs.databricks.com/gcp/en/compute/serverless/dependencies.md#project-environment-bundle).
  2. [Deploy the bundle](https://docs.databricks.com/gcp/en/dev-tools/bundles/workspace-deploy.md#deploy) to create the job.

  Schedules are paused by default in development mode. See [Declarative Automation Bundles deployment modes](https://docs.databricks.com/gcp/en/dev-tools/bundles/deployment-modes.md).

For notebook scheduling options, see [Create and manage scheduled notebook jobs](https://docs.databricks.com/gcp/en/notebooks/schedule-notebook-jobs.md).

## Limitations

* Compute sharing is scoped to a [serverless usage policy](https://docs.databricks.com/gcp/en/admin/usage/budget-policies.md). Notebooks and files in the same Git folder or bundle that use different usage policies are assigned separate compute resources instead of sharing one.

## Additional resources

* [Serverless compute for notebooks](https://docs.databricks.com/gcp/en/compute/serverless/notebooks.md)
* [Configure the serverless environment](https://docs.databricks.com/gcp/en/compute/serverless/dependencies.md)
* [Create and manage Git folders](https://docs.databricks.com/gcp/en/repos/git-operations-with-repos.md)
* [Run shell commands in the web terminal](https://docs.databricks.com/gcp/en/compute/web-terminal.md)
* [Declarative Automation Bundles](https://docs.databricks.com/gcp/en/dev-tools/bundles/index.md)
