[Opt]Support passing parameters by overriding default values through environment variables#702
Open
Potterluo wants to merge 2 commits intoModelEngine-Group:developfrom
Open
[Opt]Support passing parameters by overriding default values through environment variables#702Potterluo wants to merge 2 commits intoModelEngine-Group:developfrom
Potterluo wants to merge 2 commits intoModelEngine-Group:developfrom
Conversation
0b20ecf to
995d399
Compare
Wwwzff
reviewed
Jan 30, 2026
| @@ -1,86 +1,195 @@ | |||
| import logging | |||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def _parse_string_type(value: Any) -> Any: |
There was a problem hiding this comment.
try to use ast.literal_eval instead of building another wheel
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.
Purpose
This Pull Request introduces dynamic environment variable substitution and automatic type inference to the configuration utility. This is specifically designed to facilitate seamless configuration overrides in CI/CD pipelines and containerized environments.
Modifications
Updated ConfigUtils to support the ${VAR_NAME:-default_value} syntax. This allows the application to prioritize system environment variables while falling back to YAML defaults if the variables are unset.
Key Changes
Environment Variable Substitution
Regex Pattern: Implemented ${(\w+)(?::-([^}]*))?} to capture variable names and optional default values.
Special Character Support: The parser is designed to handle hyphens and special symbols within default values (e.g., postgresql-primary.svc.cluster.local). It splits only at the first :- sequence.
Recursive Processing: The utility now performs a deep-traversal of the YAML dictionary/list structure to ensure all nested strings are processed.
Automatic Type Conversion
To maintain data integrity, the utility now automatically casts strings to their native Python types:
Boolean: Converts "true" to True and "false"to False.
Numeric: Automatically detects and converts strings to int or float.
Test