docs(python): add doctests to builder and config APIs, enable --doctest-modules#623
Open
GayathriSrividya wants to merge 1 commit into
Open
docs(python): add doctests to builder and config APIs, enable --doctest-modules#623GayathriSrividya wants to merge 1 commit into
GayathriSrividya wants to merge 1 commit into
Conversation
…st-modules (apache#82) - Add `addopts = "--doctest-modules"` to [tool.pytest.ini_options] in pyproject.toml so pytest auto-discovers doctests in the hudi/ package. - Add runnable Examples: blocks to every public HudiTableBuilder method (from_base_uri, with_hudi_option, with_hudi_options, with_storage_option, with_storage_options, with_option, with_options). The build() example uses # doctest: +SKIP to avoid requiring a real table path. - Add Examples: blocks to HudiTableConfig, HudiReadConfig, and HudiPlanConfig showing how to access the key string from each enum (e.g. HudiTableConfig.BASE_PATH.value == 'hoodie.base.path'). Closes apache#82
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.
Summary
Closes #82.
This PR implements the doctest setup designed by @xushiyan in the issue.
Sets up Python doctest infrastructure and adds runnable
Examples:blocks to the public Python API. The blocking dependency (#141 — consolidate testing data modules) was resolved in release 0.5.0.Changes
python/pyproject.tomlAdd
addopts = "--doctest-modules"to[tool.pytest.ini_options]. Thehudi/directory was already intestpaths; this flag activates doctest discovery so the examples in docstrings are collected and run as part ofpytest.python/hudi/table/builder.pyAdd
Examples:blocks to every publicHudiTableBuildermethod (as specified by @xushiyan — "guiding example to show users the most typical use cases of the APIs and actual test cases like other unit tests"):from_base_uribase_uri, emptyhudi_options, emptystorage_optionswith_hudi_optionhudi_optionsdictwith_hudi_optionssorted()for determinismwith_storage_optionstorage_optionsdictwith_storage_optionswith_optionoptionswith_optionsbuild# doctest: +SKIPsince a real table path is requiredpython/hudi/_config.pyAdd
Examples:blocks to the three config enums, demonstrating how to read the canonical key string from an enum member:Key values were verified against the Rust
AsRef<str>implementations incrates/core/src/config/{table,read,plan}.rs.