Skip to main content

h2o-drive

Python Client for H2O Drive.

Installation

pip install h2o-drive

Usage

Connecting to H2O Drive

import h2o_drive

drive = h2o_drive.connect()

When used within the H2O AI Cloud environment or locally with the H2O AI Cloud CLI configured, no further configuration is needed.

h2o_drive.connect() can be configured via optional parameters:

  • discovery: The h2o_discovery.Discovery object through which to discover services for determining connection details
  • userdrive_url: URL to Drive's userdrive service.
  • workspace_url: URL to Drive's workspacedrive service.
  • sts_url: URL to the STS service.
  • token_provider: A token provider generating authentication credentials.

Object Operations

To perform object operations, first open any Drive bucket. For example:

bucket = drive.user_bucket()
# or
bucket = drive.workspace_bucket("default")

Buckets have the following methods:

  • upload_file() uploads a local file, resulting in a new object at the specified key in the bucket. It takes two arguments:

    • filename: The file to upload. The contents of this file will become an object in the Drive bucket.
    • key: The key at which to store the resulting object. In other words, the name attached to the object.
  • list_objects() returns the list of objects in the bucket. It takes one optional argument:

    • prefix: When specified, only objects at keys starting with the specified value are listed.
  • download_file() downloads the object at the specified key and writes it to the specified local file. It takes two arguments:

    • key: The key of the object to download.
    • filename: The file, on the local filesystem, the object is written to.
  • delete_object() deletes the object at the specified key. It takes a single argument:

    • key: The key of the object to delete.
  • generate_presigned_url() generates a presigned URL for accessing the object at the specified key in the bucket. It takes two arguments:

    • key: The key to generate a presigned URL for.
    • duration_seconds: (Optional) The duration, in seconds, for which the URL should be valid. Defaults to 1 day.
  • with_prefix() returns a prefixed view of this bucket. All the keys in each of its object operations are automatically prefixed with the specified value. It takes a single argument:

    • prefix: The key prefix to automatically apply to all object operations.

Examples

Example: Open the storage bucket for your personal H2O workspace, write a local file, and list its contents

import h2o_drive

# Prepare a local test file.
with open("test-file.txt", "w") as f:
    f.write("Hello, world!")

drive = h2o_drive.connect()
bucket = drive.workspace_bucket("default")

await bucket.upload_file("test-file.txt", "drive-test/uploaded-test-object.txt")

objects = await bucket.list_objects()
print(objects)

Metadata

Release files for h2o-drive 5.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 h2o-drive 5.1.0
File Size Uploaded
h2o_drive-5.1.0.tar.gz 13.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for h2o-drive 5.1.0
File Interpreter ABI Platform
h2o_drive-5.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 25.4 kB

Release files / h2o_drive-5.1.0.tar.gz

Download URL h2o_drive-5.1.0.tar.gz
Size 13.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ca6c9e00c4e184de2c5f9aebdc322008dad5ce3ccc02c7323ee3035d0155af10
BLAKE2b-256 checksum
How to use checksums
f8c92fb3d2a7af7926d49e97e87125d3ded26898f1de17a2af74871cf5f31efb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / h2o_drive-5.1.0-py3-none-any.whl

Download URL h2o_drive-5.1.0-py3-none-any.whl
Size 11.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1dbc58e5f0c11be0703ac2d01a3d9b11296fd29e4555af6032e67a78d16b60a3
BLAKE2b-256 checksum
How to use checksums
13ee04a8f7f52c53ec3ef83eab41cb12dfd18834d3023039afa745b95c29df04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

5.1.0 This release

2 release files

4.1.0

2 release files

4.0.0

2 release files

3.0.0

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.0.0

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