aliyun-odps-python-sdk

The official Python SDK for Alibaba Cloud MaxCompute (ODPS), with a pandas-like DataFrame API and Jupyter integration.

SDK
PyPI
v0.13.1
449stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
68/100Good
Development Activity56
Maintenance60
Community76
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
70/100Good
Architecture74
Code Quality72
Innovation68
Learning Curve65

PyODPS is Alibaba Cloud’s official Python SDK for MaxCompute (formerly known as ODPS), the company’s big-data processing platform. It wraps the MaxCompute REST API in a Pythonic object model — projects, tables, partitions, instances, resources, and functions are all first-class objects with list, get, exist, create, and delete operations, so developers can manage MaxCompute assets and run SQL/MapReduce jobs without hand-rolling HTTP calls or XML parsing.

Beyond the raw API wrapper, PyODPS ships odps.df, a DataFrame abstraction that lets users write pandas-like expressions (table.filter(...).groupby(...).agg(...)) that compile down to MaxCompute SQL or a local pandas execution backend, and odps.tunnel, a high-throughput binary tunnel (with a Cython-accelerated protobuf/CRC layer) for bulk upload and download of table data. The library also registers a SQLAlchemy dialect and an Apache Superset engine spec, so MaxCompute can be queried through either as a normal database backend.

For interactive workflows, PyODPS includes an IPython/Jupyter extension (%load_ext odps) that adds %%sql and %enter magics for running MaxCompute SQL and switching project context from a notebook, plus a pyou CLI for locally debugging Python UDFs before deploying them to MaxCompute. An odps.ml module wraps MaxCompute’s built-in machine-learning algorithms (classification, clustering, regression, feature engineering) behind a scikit-learn-flavored pipeline API.

What You Get

  • An ODPS client object exposing project, table, partition, instance, resource, and function management with list/get/create/delete semantics
  • odps.df, a pandas-like DataFrame expression layer that compiles to MaxCompute SQL or runs locally against pandas
  • A Cython-accelerated tunnel protocol (odps.tunnel) for high-throughput bulk table upload/download and streaming reads
  • A SQLAlchemy dialect and Apache Superset engine spec, so MaxCompute can be queried via standard SQLAlchemy tooling or visualized in Superset
  • IPython/Jupyter magics (%load_ext odps, %enter, %sql) for interactive project switching and SQL execution in notebooks
  • A pyou CLI for locally testing Python UDFs against sample input before deploying them to MaxCompute
  • odps.ml, a pipeline API over MaxCompute’s built-in machine-learning algorithms for classification, clustering, regression, and feature engineering

Common Use Cases

  • Automating MaxCompute table and partition lifecycle management (create, list, drop) from Python scripts or CI pipelines
  • Running and monitoring MaxCompute SQL/MapReduce jobs programmatically instead of through the web console
  • Bulk-loading or extracting large tables to/from MaxCompute using the tunnel API instead of row-by-row SQL
  • Querying MaxCompute from BI tools via the SQLAlchemy dialect or building Superset dashboards against it
  • Prototyping and debugging Python UDFs locally with pyou before publishing them to a MaxCompute project
  • Exploratory data analysis in Jupyter using odps.df DataFrame expressions that push computation into MaxCompute

Under The Hood

Architecture The library is organized around a central ODPS class (odps/core.py) that composes a RestClient (odps/rest.py), an account/auth layer (odps/accounts.py), and a models package (odps/models/) representing MaxCompute resources — projects, tables, instances, partitions, functions, resources — each as its own module with list/get/create/delete operations wired back through the shared REST client. Configuration is centralized through a global options object (odps/config.py), and a DAG implementation (odps/dag.py) underpins job/task dependency resolution for instances. Bulk data movement is split into its own odps/tunnel/ subpackage with a Cython-accelerated I/O layer (odps/tunnel/pb, checksum_c.pyx, hasher_c.pyx) separate from the REST-based control plane, and odps/df/ layers a pandas-like expression/compiler stack (expr, backends, engines) on top of both the REST models and the tunnel for execution. This is a layered, moderately modular design: REST control plane, tunnel data plane, and DataFrame compiler are cleanly separated, though odps.ml, odps.df, and the SQLAlchemy/Superset integrations add substantial surface area attached to the same core ODPS object. Tech Stack PyODPS targets Python 3.7+ (with PyPy support) and depends on requests for HTTP and pyarrow for columnar data interchange, with an optional full extra pulling in jupyter, ipython, numpy, pandas, matplotlib, graphviz, greenlet, and cython. Performance-sensitive tunnel code (CRC/hashing/protobuf framing) is written in Cython and compiled via setuptools with a cibuildwheel-based GitHub Actions release pipeline that builds wheels for Linux/macOS/Windows across many CPython versions. The package registers itself as a SQLAlchemy dialect entry point and a Superset db_engine_spec, and ships three console scripts (pyou, pyodps-pack, pyodpswrapper) via pyproject.toml [project.scripts]. Code Quality The project has an extensive test suite (130+ test_*.py files across odps/tests, odps/tunnel/tests, odps/df/tests, odps/ml/tests) run with pytest against a real or mocked MaxCompute account, plus flake8 (via setup.cfg), black, and isort configuration enforced through .pre-commit-config.yaml. Error handling favors explicit, typed exceptions parsed from MaxCompute’s XML/JSON error responses (odps/errors.py defines DatetimeOverflowError, DependencyNotInstalledError, and dozens of API-specific error classes) rather than swallowing failures. The codebase predates widespread Python type-hint adoption (no typing imports found), reflecting its long history supporting Python 2 and PyPy compatibility, and naming/module layout is generally consistent across the models, tunnel, and df subpackages. What Makes It Unique Unlike a typical thin cloud-SDK wrapper, PyODPS bundles a full DataFrame query-compilation layer (odps.df) that can push pandas-style expressions down into MaxCompute SQL or execute them locally, plus a machine-learning pipeline layer (odps.ml) over MaxCompute’s built-in ML algorithms — combining API client, distributed-SQL DataFrame engine, and ML pipeline tooling in one package where comparable cloud SDKs typically only offer the first.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search