This package provides a native Python binding for Apache OpenDAL™, a data access layer that allows you to access various storage services in a unified way.
async API for modern Python applications.Install the package directly from PyPI:
pip install opendal
Here are a few examples of how to use OpenDAL with different storage backends.
fs)import opendal # Initialize the operator for the local filesystem op = opendal.Operator("fs", root="/tmp") # Write data to a file op.write("test.txt", b"Hello World") # Read data from the file content = op.read("test.txt") print(op.read("test.txt")) # Get metadata metadata = op.stat("test.txt") print(f"Content length: {metadata.content_length}") # Output: 11
The API remains the same—just change the scheme and credentials.
import opendal # Initialize the operator for S3 op = opendal.Operator( "s3", bucket="your_bucket_name", region="your_region", root="/path/to/root" ) op.write("test.txt", b"Hello World") print(op.read("test.txt")) print(op.stat("test.txt").content_length)
s3)OpenDAL also provides a fully asynchronous API.
import asyncio import opendal async def main(): # Use AsyncOperator for async operations op = opendal.AsyncOperator("s3", root="/tmp", bucket="your_bucket_name", region="your_region") await op.write("test.txt", b"Hello World") print(await op.read("test.txt")) asyncio.run(main())
This project uses just as a command runner to simplify the development workflow.
Clone the repository and set up the environment:
# This will create a virtual environment and install all dependencies just setup
Run tests:
# Example: Run tests for the 'fs' operator OPENDAL_TEST=fs OPENDAL_FS_ROOT=/tmp just test
For a complete guide on building, testing, and contributing, please see our CONTRIBUTING.md file.
Check out the users list for more details on who is using OpenDAL.
Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
Apache OpenDAL, OpenDAL, and Apache are either registered trademarks or trademarks of the Apache Software Foundation.