Skip to main content
The Python SDK is a client for the dataerai transfer daemon. Its methods are blocking, so they’re easy to use in a script or a Jupyter notebook. The daemon starts automatically if it isn’t already running.

Requirements

  • Python 3.10+
  • The dataerai binary on your PATH (see the CLI overview), or pass binary_path explicitly.
  • Signed in with dataerai auth login (see Authenticate).

Install

pip install dataerai

Quickstart

from dataerai import DataEraiClient

with DataEraiClient(binary_path="/usr/local/bin/dataerai") as client:
    # Who am I?
    status = client.auth_status()
    print(f"Logged in as {status.user_email}")

    # Upload a file
    result = client.upload(
        "/path/to/data.csv",
        title="My dataset",
        owner_type="project",
        owner_id="proj-abc123",
        tags=["csv", "demo"],
        on_progress=lambda p: print(f"  {p.percent:.0f}%  {p.rate_mbps:.1f} MB/s"),
    )
    print(f"Uploaded asset_id={result.asset_id}")

    # Download it back
    dl = client.download(result.asset_id, dest_dir="/tmp/downloads")
    for f in dl.files:
        print(f"  {f.local_path} ({f.size:,} bytes)")

    # Read and update metadata
    meta = client.get_metadata(result.asset_id)
    client.set_metadata(result.asset_id, title="My dataset v2", tags=["csv", "demo"])
Use the client as a context manager (with ... as client:) for automatic cleanup, or call client.connect() and client.close() yourself.

Methods

MethodReturnsDescription
auth_status()AuthStatusLogged-in user and token expiry.
upload(local_path, *, title, owner_type, owner_id, ...)UploadResultUpload a file; blocks until complete.
download(asset_id, dest_dir, ...)DownloadResultDownload the latest content; blocks until complete. Resumes automatically.
get_metadata(asset_id)AssetMetadataRetrieve metadata.
set_metadata(asset_id, **fields)AssetMetadataUpdate metadata fields.

upload() arguments

title, owner_type ("project" or "collection"), and owner_id are required. Optional: description, alias, tags, metadata (dict), collection_id, chunk_size_mb, on_progress (callback), and transfer_timeout_s (default 3600). The on_progress callback receives a ProgressEvent with bytes_done, bytes_total, file_name, and convenience percent and rate_mbps properties.

Errors

ExceptionWhen
DaemonError(code, message)The daemon returned a coded error.
DaemonTimeoutErrorA request or transfer exceeded its timeout.
ConnectionErrorThe daemon disconnected unexpectedly.

Next steps

CLI

The command-line client the SDK builds on.

Node SDK

The same operations from Node.js.