Registry / data / opendatalab

opendatalab

JSON →
library0.0.10pypypi✓ verified 22d ago

The OpenDataLab Python SDK (version 0.0.10) is a library designed for programmatic access to the OpenDataLab platform and its open datasets. It provides a Pythonic interface to resources and includes a command-line interface (CLI) tool, `odl`, for convenient dataset operations. The SDK is currently a work-in-progress (WIP), and users are advised to use the latest version as compatibility across releases is not guaranteed.

pip install opendatalab
INSTALL
IMPORT
SIG · OPENDATALAB
O
opendatalab
datapythonv0.0.10
Install
8.6s avg
Import
572ms
Disk
76MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.0.10 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.570s · 73.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 8.6s · import 0.574s · 75MB
76MB installed
● package 76MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Client
from opendatalab import Client
from opendatalab.client import OdlClient

This quickstart demonstrates how to initialize the `OdlClient` and conceptually interact with the OpenDataLab platform to download a dataset. Note that an OpenDataLab account is required, and the current official documentation primarily emphasizes the CLI tool `odl` for these operations. While the SDK provides the underlying Pythonic access, direct Python examples for authentication and dataset download are less prominent in the main README. It is recommended to use the `odl login` command-line tool to establish a session before using the SDK programmatically for certain operations if direct client-side login methods are not explicitly detailed.

import os from opendatalab.client import OdlClient # An OpenDataLab account is required. Register at https://opendatalab.org.cn/ # Set your credentials as environment variables or pass them directly. USERNAME = os.environ.get('OPEN_DATALAB_USERNAME', 'your_username') PASSWORD = os.environ.get('OPEN_DATALAB_PASSWORD', 'your_password') # Initialize the client odl_client = OdlClient() try: # Login to the OpenDataLab platform print(f"Attempting to log in as {USERNAME}...") # The SDK's client methods usually mirror the CLI, but direct programmatic login might vary. # As per CLI, it typically involves a login command. The OdlClient likely handles session management. # For this quickstart, we'll assume the client manages authentication after init or first call. # Actual login might be handled via `odl login` CLI or specific client method. # For direct Python SDK usage, you would typically configure credentials during client init or through a dedicated login method. # Given the CLI-heavy documentation, a direct 'login' method on OdlClient is likely, though not explicitly shown in public docs in detail. # For demonstration, we'll assume an authenticated state for 'get' after setting up credentials indirectly/via CLI 'odl login'. # In a real scenario, ensure you are logged in using `odl login` first, or check for a client-side login method. # The provided client object often carries session information. # Example: Get (download) a dataset (replace 'dataset-id' with a real one) print("Attempting to list datasets (requires login/session)...") # No direct 'list' method found in quick search for OdlClient, focusing on 'get' as per CLI doc. # The CLI 'odl get' downloads a dataset. # Let's simulate a download call, assuming authentication is handled. dataset_id = 'YOUR_DATASET_ID' # e.g., 'mnist' destination_path = './downloaded_dataset' print(f"Attempting to download dataset '{dataset_id}' to '{destination_path}'...") # This method signature is inferred from CLI `odl get` and common SDK patterns. # You might need to check actual SDK source or documentation for exact method names/arguments. # odl_client.get(dataset_id, destination_path) print(f"Please use the CLI 'odl login' and 'odl get {dataset_id} -o {destination_path}' for actual usage as per current documentation.") print("The Python SDK offers underlying access, but CLI is primary documented interface for these actions.") except Exception as e: print(f"An error occurred: {e}")
odl --version
Debug
Known issues
breakingThe OpenDataLab SDK is explicitly marked as 'WIP' (Work-In-Progress), and the developers 'not ensure the necessary compatibility of OpenAPI and SDK'. This means that breaking changes can occur frequently, and API stability is not guaranteed across minor versions.
fix
Always use the latest version of the SDK and be prepared for potential API adjustments. Regularly check the GitHub repository for updates and changes.
affects: All versions (currently 0.0.10 and earlier)
gotchaAn OpenDataLab account (username and password) is required to access the platform and its datasets, even when using the SDK. Attempting to use the SDK without authentication will fail.
fix
Register for an account on the official OpenDataLab website (https://opendatalab.org.cn/) and ensure you log in using the `odl login` CLI command or a programmatic login method before accessing resources.
affects: All versions
gotchaThe primary usage examples in the official GitHub README heavily feature the `odl` command-line interface (CLI) for tasks like login and dataset retrieval. While a Python SDK exists, direct Python examples for certain common workflows might be less immediately visible compared to CLI instructions.
fix
Consult the `opendatalab-python-sdk` GitHub repository for source code examples or internal usage of the `OdlClient` if specific Pythonic implementations are not clear from high-level documentation. Be aware that the CLI might be the most stable and documented interface for certain actions in early development.
affects: All versions
Upgrade
Version history
0.0.10latest on PyPI · released Aug 2, 2023
Audit
Dependencies
clickrequiredCLI framework dependency
requestsrequiredHTTP client for API communication
tqdmrequiredProgress bar for downloads/uploads
oss2requiredObject Storage Service (OSS) client
coloramarequiredCross-platform colored terminal text
richrequiredRich text and beautiful formatting in the terminal
pywin32optionalWindows-specific functionality (platform-dependent)
Agent activity
5 hits · last 30 days
node
4
Resources