Skip to main content

notebookutils.fs: file system and mounting library

generic notebookutils.fs library on arbitrary local/VM/K8s environment, for developing and running pySpark notebooks without Databricks / Azure Synapse / Microsoft Fabric environments.

Introduction to dbutils and mssparkutils

In cloud Platform-as-a-Service (PaaS) environments, dbutils and mssparkutils are essential, built-in utility packages designed to bridge the gap between PySpark code and the underlying cloud infrastructure.

While Apache Spark natively excels at distributed data processing, it lacks built-in mechanisms for environment-specific orchestration. These vendor-specific libraries step in to provide that critical operational control layer.

  • dbutils (Databricks Utilities): The native toolset for the Databricks platform. It allows engineers to interactively navigate the Databricks File System (DBFS), securely retrieve credentials via Azure Key Vault or AWS Secrets Manager, parameterize notebooks using widgets, and chain multiple notebooks into modular workflows.
  • mssparkutils / notebookutils in Fabric (Microsoft Spark Utilities): The direct counterpart built for Microsoft Azure Synapse Analytics and Microsoft Fabric. It offers near-identical functionality and APIs tailored for the Microsoft ecosystem, enabling developers to manage files in Azure Data Lake Storage (ADLS) Gen2, handle Microsoft Entra ID tokens, and control notebook pipeline execution paths.

Ultimately, both mssparkutils and dbutils abstract away complex cloud APIs, allowing data engineers to write secure, scalable, and maintainable data pipelines without leaving their interactive pySpark notebook environments.

Technical overview of notebookutils.fs

Cloud file operations(put, get, rm) use fsspec backend. While the original dbutils use hadoop backend via Py4J, this library choose fsspec for compatibility with non-Spark environments, such as pure python, DuckDB and StarRocks.

POSIX mounts use

  • blobfuse v2 for Azure Blob Storage and ADLFS G2
  • s3-mount for Amazon S3 and s3-compatible object storage(OVH/Hertzner/DigitalOcean/Linode etc)
  • gcsfuse for Google Cloud Storage

Installation

Install notebookutils

pip install notebookutils

Cloud storage backends are optional extras — install only what you need:

pip install notebookutils[s3]     # Amazon S3 / S3-compatible (s3fs)
pip install notebookutils[azure]  # ADLS Gen2 / Blob (adlfs + azure-identity)
pip install notebookutils[gcs]    # Google Cloud Storage (gcsfs)
pip install notebookutils[all]    # everything

For POSIX mounting, install the FUSE binary for your storage type: mount-s3, blobfuse2, or gcsfuse.

Usage

from notebookutils import fs

# Memory-space file operations (fsspec-backed)
fs.ls("s3://my-bucket/data")                    # -> [FileInfo(...), ...]
fs.put("s3://my-bucket/hello.txt", "hi", overwrite=True)
fs.head("s3://my-bucket/hello.txt")
fs.cp("s3://my-bucket/data", "abfss://cont@acct.dfs.core.windows.net/data", recurse=True)  # cross-cloud
fs.mkdirs("gs://my-bucket/new_dir")
fs.exists("s3://my-bucket/hello.txt")
fs.rm("s3://my-bucket/hello.txt")

# POSIX mounting (FUSE-backed, process-safe)
fs.mount("s3://my-bucket", "/mydata")
path = fs.getMountPath("/mydata")
with open(f"{path}/hello.txt") as f:
    print(f.read())
fs.mounts()          # list active mount points
fs.unmount("/mydata")

fs.help()            # full API overview

Legacy Synapse code works too: import notebookutils installs an in-session mssparkutils alias, or simply import notebookutils as mssparkutils.

Full API documentation: see MANUAL.md.

Explicit configuration (optional)

If environment discovery isn't enough (e.g. S3-compatible endpoints), override per protocol:

fs.configure("s3", key="...", secret="...",
             client_kwargs={"endpoint_url": "https://minio.example:9000"},
             mount_options={"allow_other": False})

Configuration Files

notebookutils use the same environmental credentials as major cloud vendor SDKs for authenticating to cloud storage. This includes:

  • DefaultAzureCredential Chain
  • AWS Boto3 Default Credential Provider Chain
  • GCP Application Default Credentials Chain
  • ~/.aws/credentials for generic S3-compatible storage

The expectation is if you can access storage with cloud vendor python SDKs, notebookutils.fs is able to access and mount storage.

Development

pip install -e '.[dev]'
pytest tests/unit          # unit tests (no credentials needed)
python -m build            # build sdist + wheel

Integration tests (opt-in)

Integration tests use the same credential chains as the official SDKs and are skipped unless credentials resolve and target URLs are set:

Env var Example Marker
NBU_TEST_S3_URL s3://my-test-bucket/ci -m s3
NBU_TEST_ABFS_URL abfss://cont@acct.dfs.core.windows.net/ci -m azure
NBU_TEST_GCS_URL gs://my-test-bucket/ci -m gcs
pytest tests/integration -m s3        # requires AWS credentials + NBU_TEST_S3_URL
pytest tests/integration -m fuse      # additionally requires FUSE binaries

Metadata

Release files for notebookutils-py 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for notebookutils-py 0.1.0
File Size Uploaded
notebookutils_py-0.1.0.tar.gz 32.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for notebookutils-py 0.1.0
File Interpreter ABI Platform
notebookutils_py-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 59.0 kB

Release files / notebookutils_py-0.1.0.tar.gz

Download URL notebookutils_py-0.1.0.tar.gz
Size 32.4 kB
Tags Source
SHA-256 checksum
How to use checksums
7b0732849f51c7827395cc7cd9712c3b320eadfb754fac8cdf773a7d259eec84
BLAKE2b-256 checksum
How to use checksums
700c5ed02937387e75347f4002a81ad4cec6c3d28d86278dfd9d200336771117
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / notebookutils_py-0.1.0-py3-none-any.whl

Download URL notebookutils_py-0.1.0-py3-none-any.whl
Size 26.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7ac35947bc6967029eccf570a1b2e483647eb0ba6aa949e165f8c475117921b7
BLAKE2b-256 checksum
How to use checksums
4e13613445ef73ac43937bf8764e45dc281db9682a31c31c0bb0bcb7ce5e2969
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page