hide:
We welcome contributions to Apache Iceberg! To learn more about contributing to Apache Iceberg, please refer to the official Iceberg contribution guidelines. These guidelines are intended as helpful suggestions to make the contribution process as seamless as possible, and are not strict rules.
If you would like to discuss your proposed change before contributing, we encourage you to visit our Community page. There, you will find various ways to connect with the community, including Slack and our mailing lists. Alternatively, you can open a new issue directly in the GitHub repository.
For first-time contributors, feel free to check out our good first issues for an easy way to get started.
The PyIceberg Project is hosted on GitHub at https://github.com/apache/iceberg-python.
For the development, Poetry is used for packing and dependency management. You can install this using:
make install-poetry
To get started, you can run make install, which installs all the dependencies of the Iceberg library. This also installs the development dependencies. If you don't want to install the development dependencies, you need to install using poetry install --without dev instead of make install.
If you want to install the library on the host, you can simply run pip3 install -e .. If you wish to use a virtual environment, you can run poetry shell. Poetry will open up a virtual environment with all the dependencies set.
Note: If you want to use
poetry shell, you need to install it usingpip install poetry-plugin-shell. Alternatively, you can run commands directly withpoetry run.
To set up IDEA with Poetry:
For IDEA ≤2021 you need to install the Poetry integration as a plugin.
Now you‘re set using Poetry, and all the tests will run in Poetry, and you’ll have syntax highlighting in the pyproject.toml to indicate stale dependencies.
Clone the repository for local development:
git clone https://github.com/apache/iceberg-python.git cd iceberg-python pip3 install -e ".[s3fs,hive]"
Install it directly for GitHub (not recommended), but sometimes handy:
pip install "git+https://github.com/apache/iceberg-python.git#egg=pyiceberg[pyarrow]"
pre-commit is used for autoformatting and linting:
make lint
Pre-commit will automatically fix the violations such as import orders, formatting etc. Pylint errors you need to fix yourself.
In contrast to the name suggest, it doesn't run the checks on the commit. If this is something that you like, you can set this up by running pre-commit install.
You can bump the integrations to the latest version using pre-commit autoupdate. This will check if there is a newer version of {black,mypy,isort,...} and update the yaml.
Removal of old cached files generated during the Cython build process:
make clean
Helps prevent build failures and unexpected behavior by removing outdated files, ensuring that only up-to-date sources are used & the build environment is always clean.
For Python, pytest is used a testing framework in combination with coverage to enforce 90%+ code coverage.
make test
By default, S3 and ADLS tests are ignored because that require minio and azurite to be running. To run the S3 suite:
make test-s3
To run the ADLS suite:
make test-adls
To pass additional arguments to pytest, you can use PYTEST_ARGS.
make test PYTEST_ARGS="-v"
make test PYTEST_ARGS="--pdb"
To see all available pytest arguments, run make test PYTEST_ARGS="--help".
PyIceberg has integration tests with Apache Spark. Spark will create a new database and provision some tables that PyIceberg can query against.
make test-integration
This will restart the containers, to get to a clean state, and then run the PyTest suite. In case something changed in the Dockerfile or the provision script, you can run:
make test-integration-rebuild
To rebuild the containers from scratch.
Below are the formalized conventions that we adhere to in the PyIceberg project. The goal of this is to have a common agreement on how to evolve the codebase, but also using it as guidelines for newcomers to the project.
It is important to keep the Python public API compatible across versions. The Python official PEP-8 defines public methods as: Public attributes should have no leading underscores. This means not removing any methods without any notice, or removing or renaming any existing parameters. Adding new optional parameters is okay.
If you want to remove a method, please add a deprecation notice by annotating the function using @deprecated:
from pyiceberg.utils.deprecated import deprecated @deprecated( deprecated_in="0.1.0", removed_in="0.2.0", help_message="Please use load_something_else() instead", ) def load_something(): pass
Which will warn:
Call to load_something, deprecated in 0.1.0, will be removed in 0.2.0. Please use load_something_else() instead.
If you want to remove a property or notify about a behavior change, please add a deprecation notice by calling the deprecation_message function:
from pyiceberg.utils.deprecated import deprecation_message deprecation_message( deprecated_in="0.1.0", removed_in="0.2.0", help_message="The old_property is deprecated. Please use the something_else property instead.", )
Which will warn:
Deprecated in 0.1.0, will be removed in 0.2.0. The old_property is deprecated. Please use the something_else property instead.
For the type annotation the types from the Typing package are used.
PyIceberg offers support from Python 3.9 onwards, we can't use the type hints from the standard collections.
PyIceberg naturally integrates into the rich Python ecosystem, however it is important to be hesitant adding third party packages. Adding a lot of packages makes the library heavyweight, and causes incompatibilities with other projects if they use a different version of the library. Also, big libraries such as s3fs, adlfs, pyarrow, thrift should be optional to avoid downloading everything, while not being sure if is actually being used.