{"id":4997,"library":"opendatalab","title":"OpenDataLab Python SDK","description":"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.","status":"active","version":"0.0.10","language":"en","source_language":"en","source_url":"https://github.com/opendatalab/opendatalab-python-sdk","tags":["dataset","sdk","cli","data-access","wip","machine-learning"],"install":[{"cmd":"pip install opendatalab","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"CLI framework dependency","package":"click","optional":false},{"reason":"HTTP client for API communication","package":"requests","optional":false},{"reason":"Progress bar for downloads/uploads","package":"tqdm","optional":false},{"reason":"Object Storage Service (OSS) client","package":"oss2","optional":false},{"reason":"Cross-platform colored terminal text","package":"colorama","optional":false},{"reason":"Rich text and beautiful formatting in the terminal","package":"rich","optional":false},{"reason":"Windows-specific functionality (platform-dependent)","package":"pywin32","optional":true}],"imports":[{"symbol":"OdlClient","correct":"from opendatalab.client import OdlClient"}],"quickstart":{"code":"import os\nfrom opendatalab.client import OdlClient\n\n# An OpenDataLab account is required. Register at https://opendatalab.org.cn/\n# Set your credentials as environment variables or pass them directly.\nUSERNAME = os.environ.get('OPEN_DATALAB_USERNAME', 'your_username')\nPASSWORD = os.environ.get('OPEN_DATALAB_PASSWORD', 'your_password')\n\n# Initialize the client\nodl_client = OdlClient()\n\ntry:\n    # Login to the OpenDataLab platform\n    print(f\"Attempting to log in as {USERNAME}...\")\n    # The SDK's client methods usually mirror the CLI, but direct programmatic login might vary.\n    # As per CLI, it typically involves a login command. The OdlClient likely handles session management.\n    # For this quickstart, we'll assume the client manages authentication after init or first call.\n    # Actual login might be handled via `odl login` CLI or specific client method.\n    # For direct Python SDK usage, you would typically configure credentials during client init or through a dedicated login method.\n    # Given the CLI-heavy documentation, a direct 'login' method on OdlClient is likely, though not explicitly shown in public docs in detail.\n\n    # For demonstration, we'll assume an authenticated state for 'get' after setting up credentials indirectly/via CLI 'odl login'.\n    # In a real scenario, ensure you are logged in using `odl login` first, or check for a client-side login method.\n    # The provided client object often carries session information.\n\n    # Example: Get (download) a dataset (replace 'dataset-id' with a real one)\n    print(\"Attempting to list datasets (requires login/session)...\")\n    # No direct 'list' method found in quick search for OdlClient, focusing on 'get' as per CLI doc.\n    # The CLI 'odl get' downloads a dataset.\n    # Let's simulate a download call, assuming authentication is handled.\n    dataset_id = 'YOUR_DATASET_ID' # e.g., 'mnist'\n    destination_path = './downloaded_dataset'\n    print(f\"Attempting to download dataset '{dataset_id}' to '{destination_path}'...\")\n    # This method signature is inferred from CLI `odl get` and common SDK patterns.\n    # You might need to check actual SDK source or documentation for exact method names/arguments.\n    # odl_client.get(dataset_id, destination_path)\n    print(f\"Please use the CLI 'odl login' and 'odl get {dataset_id} -o {destination_path}' for actual usage as per current documentation.\")\n    print(\"The Python SDK offers underlying access, but CLI is primary documented interface for these actions.\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")","lang":"python","description":"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."},"warnings":[{"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.","message":"The 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.","severity":"breaking","affected_versions":"All versions (currently 0.0.10 and earlier)"},{"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.","message":"An 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"The 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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}