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.workspacedrive_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.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| h2o_drive-5.2.0.tar.gz | 15.2 kB | Without provenance | Details for h2o_drive-5.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| h2o_drive-5.2.0-py3-none-any.whl | Python 3 | none | any | Details for h2o_drive-5.2.0-py3-none-any.whl |
Total release size: 28.2 kB
Release files / h2o_drive-5.2.0.tar.gz
| Download URL | h2o_drive-5.2.0.tar.gz |
|---|---|
| Size | 15.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
49e22cfafe0ba42240050c6715e9d7d0b1ab395a86a81be5ae43bc83c1906653
|
|
BLAKE2b-256 checksum How to use checksums |
44139abf9e8563f01ed17e1673b043955f52d3406f3c04ef518d2c3010d93e0b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / h2o_drive-5.2.0-py3-none-any.whl
| Download URL | h2o_drive-5.2.0-py3-none-any.whl |
|---|---|
| Size | 13.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b5c1772a166b6507b96b836072a6c9d5191ba40723b172b39de167053e725b6f
|
|
BLAKE2b-256 checksum How to use checksums |
a1d9d4072c1defed7ccffe7a9c2a130de672277f997e8e01c5f1743ef5287d83
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for h2o-drive 5.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.