{"library":"openxlab","title":"OpenXLab Python SDK","description":"OpenXLab is a Python library providing tools to interact with the OpenXLab platform, focusing on managing datasets and models. It includes a command-line interface (CLI) and a Python SDK to programmatically access platform features such as dataset information, upload, and download. The library is currently at version 0.1.3 and appears to have a regular release cadence, with updates often reflecting platform-level changes within the broader OpenXLab ecosystem.","status":"active","version":"0.1.3","language":"en","source_language":"en","source_url":"https://github.com/OpenDataLab/","tags":["machine-learning","ai","datasets","data-management","cloud-platform","utilities"],"install":[{"cmd":"pip install openxlab","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"HTTP communication with OpenXLab platform.","package":"requests"},{"reason":"Progress bars for file transfers.","package":"tqdm"},{"reason":"Interacting with object storage service for data operations.","package":"oss2"},{"reason":"Build and distribution utility; specific versions have caused conflicts.","package":"setuptools","optional":true}],"imports":[{"symbol":"get","correct":"from openxlab.dataset import get"},{"symbol":"upload_folder","correct":"from openxlab.dataset import upload_folder"},{"note":"The token utility is nested within `xlab.handler.user_token`.","wrong":"from openxlab.token import get_jwt","symbol":"get_jwt","correct":"from openxlab.xlab.handler.user_token import get_jwt"}],"quickstart":{"code":"import os\nfrom openxlab.xlab.handler.user_token import get_jwt\nfrom openxlab.dataset import get\n\n# Set your Access Key and Secret Key as environment variables\n# These can be obtained from your OpenXLab user center.\n# For example: export OPENXLAB_AK=\"YOUR_AK_HERE\"\n# For example: export OPENXLAB_SK=\"YOUR_SK_HERE\"\nak = os.environ.get('OPENXLAB_AK', 'YOUR_AK_HERE')\nsk = os.environ.get('OPENXLAB_SK', 'YOUR_SK_HERE')\n\nif ak == 'YOUR_AK_HERE' or sk == 'YOUR_SK_HERE':\n    print(\"Please set OPENXLAB_AK and OPENXLAB_SK environment variables or replace placeholders.\")\n    # Attempt to use CLI config if env vars are not set for demonstration purposes\n    # In a real scenario, user would run 'openxlab config' or set env vars.\n    # For programmatic access, env vars are preferred.\nelse:\n    try:\n        # Authenticate and get a JWT token\n        token = get_jwt(ak=ak, sk=sk)\n        print(f\"Successfully obtained JWT token (first 10 chars): {token[:10]}...\")\n\n        # Example: Get (download) a public dataset\n        # Replace 'OpenDataLab/MNIST' with a valid dataset repository and adjust target_path\n        # Ensure the target_path exists or can be created.\n        dataset_repo_name = 'OpenDataLab/MNIST'\n        target_download_path = './MNIST_dataset'\n        print(f\"\\nAttempting to download dataset: {dataset_repo_name} to {target_download_path}\")\n        \n        # Create a dummy directory for download if it doesn't exist\n        os.makedirs(target_download_path, exist_ok=True)\n\n        # Note: The 'get' function might automatically use configured AK/SK,\n        # but explicit authentication often precedes other SDK calls.\n        get(dataset_repo=dataset_repo_name, target_path=target_download_path)\n        print(f\"Dataset '{dataset_repo_name}' downloaded to '{target_download_path}' successfully.\")\n\n    except Exception as e:\n        print(f\"An error occurred: {e}\")\n        print(\"Ensure your AK/SK are correct and you have network access to OpenXLab.\")\n","lang":"python","description":"This quickstart demonstrates how to authenticate with OpenXLab using environment variables for Access Key (AK) and Secret Key (SK), and then how to use the `openxlab.dataset.get` function to download a public dataset. Replace 'YOUR_AK_HERE' and 'YOUR_SK_HERE' with your actual credentials, or ideally, set them as environment variables (OPENXLAB_AK, OPENXLAB_SK). The example attempts to download the 'OpenDataLab/MNIST' dataset, which is a common public dataset."},"warnings":[{"fix":"While potentially resolved in newer versions, if you encounter `setuptools` conflicts, try isolating `openxlab` in a virtual environment or explicitly pinning `setuptools` to a compatible version as a temporary workaround. Check release notes for explicit dependency updates.","message":"Older versions of `openxlab` (e.g., 0.0.37) have been reported to have `setuptools` dependency conflicts (requiring `~=60.2.0` while other packages might need newer versions).","severity":"gotcha","affected_versions":"<0.1.0"},{"fix":"Always ensure your `OPENXLAB_AK` and `OPENXLAB_SK` environment variables are correctly set and valid, or that `openxlab config` has been run. Verify network connectivity to the OpenXLab API endpoints. For programmatic access, using environment variables is the most recommended and secure approach.","message":"Authentication (Access Key and Secret Key) is crucial. If not configured via `openxlab config`, `~/.openxlab/config.json`, or environment variables (`OPENXLAB_AK`, `OPENXLAB_SK`), API calls will fail. Direct `openxlab.login` or SDK calls can also fail with 503 Server Error if the backend service is unavailable.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Refer to the official OpenXLab documentation (浦源-文档中心) for the most accurate and up-to-date SDK usage patterns and import paths. Confirm you are installing the correct `openxlab` package (`pip install openxlab`) if interacting with the OpenXLab platform.","message":"The `openxlab` PyPI package and its GitHub presence can be confusing due to similar names with other projects (e.g., `OpenXLA`, `openclaw`) and its integration within a broader OpenXLab/OpenDataLab ecosystem. The primary source for the Python SDK functionality for datasets and models resides within modules imported from `openxlab`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-05T00:00:00.000Z","next_check":"2026-07-04T00:00:00.000Z"}