refactor(config): centralize env var parsing helpers#3453
Merged
Conversation
Add `helpers.get_env_int` and `helpers.get_env_path` for consistent env var handling. `get_env_int` raises an informative `ValueError` on malformed input; `get_env_path` returns `pl.Path | None`. Make `CARDANO_NODE_SOCKET_PATH` a required var with an explicit `RuntimeError` on missing value (was implicit `KeyError`). Drop redundant `pl.Path(...)` re-wraps at consumers now that `BOOTSTRAP_DIR`, `SCHEDULING_LOG`, and `BLOCK_PRODUCTION_DB` carry proper `Path` types. The xdist scheduler keeps a local copy of the int helper to avoid importing the framework package from the pytest plugin.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR centralizes environment-variable parsing to reduce duplicated logic and make configuration handling more consistent across the framework, while also improving failure modes for missing/malformed values.
Changes:
- Added
helpers.get_env_intandhelpers.get_env_pathand migrated several env var reads to use them. - Made
CARDANO_NODE_SOCKET_PATHexplicitly required at configuration load time, raising a clearerRuntimeErrorwhen missing. - Updated consumers to treat
BOOTSTRAP_DIR,SCHEDULING_LOG, andBLOCK_PRODUCTION_DBaspathlib.Path(orNone) and removed redundantpl.Path(...)re-wrapping; kept a local int helper in the xdist scheduler plugin to avoid framework imports.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| cardano_node_tests/utils/versions.py | Uses centralized int env parsing for PROTOCOL_VERSION. |
| cardano_node_tests/utils/helpers.py | Introduces get_env_int / get_env_path helpers for consistent env var parsing. |
| cardano_node_tests/utils/dbsync_service_manager.py | Avoids redundant Path(...) wrapping for BOOTSTRAP_DIR usage. |
| cardano_node_tests/utils/configuration.py | Centralizes env parsing, makes socket path required, and normalizes path-typed config values. |
| cardano_node_tests/utils/cluster_scripts.py | Removes redundant Path(...) wrapping when consuming BOOTSTRAP_DIR. |
| cardano_node_tests/tests/tests_plutus_v3/test_mint_build.py | Uses centralized int env parsing for UPGRADE_TESTS_STEP. |
| cardano_node_tests/tests/test_xdist_helper.py | Uses centralized int env parsing for xdist worker count. |
| cardano_node_tests/tests/test_rollback.py | Uses centralized int env parsing for ROLLBACK_NODES_OFFSET. |
| cardano_node_tests/tests/test_node_upgrade.py | Uses centralized int env parsing for UPGRADE_TESTS_STEP. |
| cardano_node_tests/tests/test_blocks.py | Uses centralized int env parsing for BLOCK_PRODUCTION_EPOCHS and tightens DB path assumption. |
| cardano_node_tests/tests/conftest.py | Stops re-wrapping BOOTSTRAP_DIR and uses it as a Path. |
| cardano_node_tests/pytest_plugins/xdist_scheduler.py | Adds local _get_env_int and uses it for CLUSTERS_COUNT parsing without framework imports. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Add
helpers.get_env_intandhelpers.get_env_pathfor consistent env var handling.get_env_intraises an informativeValueErroron malformed input;get_env_pathreturnspl.Path | None.Make
CARDANO_NODE_SOCKET_PATHa required var with an explicitRuntimeErroron missing value (was implicitKeyError). Drop redundantpl.Path(...)re-wraps at consumers now thatBOOTSTRAP_DIR,SCHEDULING_LOG, andBLOCK_PRODUCTION_DBcarry properPathtypes.The xdist scheduler keeps a local copy of the int helper to avoid importing the framework package from the pytest plugin.