Improved optional dependencies handling - #603
Open
probberechts wants to merge 1 commit into
Open
Conversation
- Add import_optional_dependency utility to handle optional packages (pandas, polars, pyarrow, networkx, s3fs) with version verification and informative error messages. - Add skip_if_no test helper to conditionally skip unit tests when optional dependencies are missing. - Add [all] extra to pyproject.toml for installing all optional dependencies. - Modularize monolithic kloppy/utils.py into scoped submodules under kloppy/_utils/ (optional, io, testing, strings, logging, deprecation, docstrings). - Update documentation in user installation guide and contributor guidelines. Co-authored-by: Zhuoling Li <loveyjudith@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR improves how optional dependencies are handled in kloppy.
Previously, checking for optional packages required scattering
try/except ImportErrorblocks throughout the codebase. This PR introduces a centralized utility,import_optional_dependency, which elegantly handles missing packages by:or conda to install pandas").
Code Example:
It also adds a
@skip_if_notesting decorator to easily skip unit tests in environments where these optional dependencies aren't installed. In the future, this will allow adding a dedicated CI job that installs only the core kloppy dependencies and tests that the base library functions perfectly for users who install the minimal version.