Fix regression: restore config validate() call in config.py#2690
Fix regression: restore config validate() call in config.py#2690maobaolong merged 8 commits intoLMCache:devfrom
Conversation
Fix regression: Add _update_config_from_env to namespace_extras The _validate_config function at line 504 was not being called after commit 3d88cee because the custom _update_config_from_env method was removed from namespace_extras, causing the config to use the base implementation which doesn't call validate(). This commit: - Adds _update_config_from_env back to namespace_extras - Updates the method to use the new _resolve_config_aliases signature - Adds a regression test to verify validate() is called The fix ensures that validation logic (like auto-setting save_unfull_chunk for PD mode) is properly executed when configs are updated from env vars. Signed-off-by: Tony Lin <tony.lin@intel.com>
|
hi @maobaolong would you like to take a look? the regression seems to be introduced by 3d88cee, but i'm not 100% sure if this is intentional. please double confirm. thanks. |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a regression that prevented configuration validation from executing when settings were loaded from environment variables. By restoring the custom Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request effectively addresses a regression where the validate() method was not being called when updating configuration from environment variables. The fix correctly restores the custom _update_config_from_env method to the LMCacheEngineConfig's namespace and updates its implementation to be consistent with recent changes in the base configuration class. The addition of a regression test is excellent, as it specifically verifies that the validation logic is now triggered as expected. I have one suggestion to improve the maintainability of the new test case.
| # Set up environment for PD mode which requires validation | ||
| os.environ["LMCACHE_ENABLE_PD"] = "true" | ||
| os.environ["LMCACHE_PD_ROLE"] = "sender" | ||
| os.environ["LMCACHE_PD_BUFFER_SIZE"] = "1024" | ||
| os.environ["LMCACHE_PD_BUFFER_DEVICE"] = "cpu" | ||
| os.environ["LMCACHE_SAVE_UNFULL_CHUNK"] = "false" | ||
|
|
||
| try: | ||
| # Create a config and update from env | ||
| config = LMCacheEngineConfig.from_defaults() | ||
| config.update_config_from_env() | ||
|
|
||
| # If validate() was called, save_unfull_chunk should be auto-set to True | ||
| # because PD mode requires it (see line 558-564 in config.py) | ||
| assert config.save_unfull_chunk is True, ( | ||
| "validate() was not called - save_unfull_chunk should be True for PD mode" | ||
| ) | ||
| finally: | ||
| # Clean up environment | ||
| del os.environ["LMCACHE_ENABLE_PD"] | ||
| del os.environ["LMCACHE_PD_ROLE"] | ||
| del os.environ["LMCACHE_PD_BUFFER_SIZE"] | ||
| del os.environ["LMCACHE_PD_BUFFER_DEVICE"] | ||
| del os.environ["LMCACHE_SAVE_UNFULL_CHUNK"] |
There was a problem hiding this comment.
The setup and cleanup of environment variables in this test are a bit repetitive. To improve maintainability and reduce duplication, you could define the environment variables in a dictionary and then iterate over it for both setting them up and tearing them down. This would make it easier to add or remove variables in the future, as you'd only need to change them in one place. Using os.environ.pop() in the cleanup is also slightly more robust than del.
# Set up environment for PD mode which requires validation
env_vars = {
"LMCACHE_ENABLE_PD": "true",
"LMCACHE_PD_ROLE": "sender",
"LMCACHE_PD_BUFFER_SIZE": "1024",
"LMCACHE_PD_BUFFER_DEVICE": "cpu",
"LMCACHE_SAVE_UNFULL_CHUNK": "false",
}
for key, value in env_vars.items():
os.environ[key] = value
try:
# Create a config and update from env
config = LMCacheEngineConfig.from_defaults()
config.update_config_from_env()
# If validate() was called, save_unfull_chunk should be auto-set to True
# because PD mode requires it (see line 558-564 in config.py)
assert config.save_unfull_chunk is True, (
"validate() was not called - save_unfull_chunk should be True for PD mode"
)
finally:
# Clean up environment
for key in env_vars:
os.environ.pop(key, None)|
hi @maobaolong , just make sure you're aware of this PR... if you have other solutions, please comments. thx. |
maobaolong
left a comment
There was a problem hiding this comment.
LGTM. Thanks for your fix.
…2690) Fix regression: Add _update_config_from_env to namespace_extras The _validate_config function at line 504 was not being called after commit 3d88cee because the custom _update_config_from_env method was removed from namespace_extras, causing the config to use the base implementation which doesn't call validate(). This commit: - Adds _update_config_from_env back to namespace_extras - Updates the method to use the new _resolve_config_aliases signature - Adds a regression test to verify validate() is called The fix ensures that validation logic (like auto-setting save_unfull_chunk for PD mode) is properly executed when configs are updated from env vars. Signed-off-by: Tony Lin <tony.lin@intel.com>
…2690) Fix regression: Add _update_config_from_env to namespace_extras The _validate_config function at line 504 was not being called after commit 3d88cee because the custom _update_config_from_env method was removed from namespace_extras, causing the config to use the base implementation which doesn't call validate(). This commit: - Adds _update_config_from_env back to namespace_extras - Updates the method to use the new _resolve_config_aliases signature - Adds a regression test to verify validate() is called The fix ensures that validation logic (like auto-setting save_unfull_chunk for PD mode) is properly executed when configs are updated from env vars. Signed-off-by: Tony Lin <tony.lin@intel.com> Signed-off-by: Aaron Wu <aaron.wu@dell.com>
…2690) Fix regression: Add _update_config_from_env to namespace_extras The _validate_config function at line 504 was not being called after commit 3d88cee because the custom _update_config_from_env method was removed from namespace_extras, causing the config to use the base implementation which doesn't call validate(). This commit: - Adds _update_config_from_env back to namespace_extras - Updates the method to use the new _resolve_config_aliases signature - Adds a regression test to verify validate() is called The fix ensures that validation logic (like auto-setting save_unfull_chunk for PD mode) is properly executed when configs are updated from env vars. Signed-off-by: Tony Lin <tony.lin@intel.com>
…2690) Fix regression: Add _update_config_from_env to namespace_extras The _validate_config function at line 504 was not being called after commit 3d88cee because the custom _update_config_from_env method was removed from namespace_extras, causing the config to use the base implementation which doesn't call validate(). This commit: - Adds _update_config_from_env back to namespace_extras - Updates the method to use the new _resolve_config_aliases signature - Adds a regression test to verify validate() is called The fix ensures that validation logic (like auto-setting save_unfull_chunk for PD mode) is properly executed when configs are updated from env vars. Signed-off-by: Tony Lin <tony.lin@intel.com>
…2690) Fix regression: Add _update_config_from_env to namespace_extras The _validate_config function at line 504 was not being called after commit 3d88cee because the custom _update_config_from_env method was removed from namespace_extras, causing the config to use the base implementation which doesn't call validate(). This commit: - Adds _update_config_from_env back to namespace_extras - Updates the method to use the new _resolve_config_aliases signature - Adds a regression test to verify validate() is called The fix ensures that validation logic (like auto-setting save_unfull_chunk for PD mode) is properly executed when configs are updated from env vars. Signed-off-by: Tony Lin <tony.lin@intel.com>
…2690) Fix regression: Add _update_config_from_env to namespace_extras The _validate_config function at line 504 was not being called after commit 3d88cee because the custom _update_config_from_env method was removed from namespace_extras, causing the config to use the base implementation which doesn't call validate(). This commit: - Adds _update_config_from_env back to namespace_extras - Updates the method to use the new _resolve_config_aliases signature - Adds a regression test to verify validate() is called The fix ensures that validation logic (like auto-setting save_unfull_chunk for PD mode) is properly executed when configs are updated from env vars. Signed-off-by: Tony Lin <tony.lin@intel.com>
Fix regression(#2510): Add _update_config_from_env to namespace_extras The _validate_config function at line 504 was not being called after commit 3d88cee because the custom _update_config_from_env method was removed from namespace_extras, causing the config to use the base implementation which doesn't call validate().
This commit:
The fix ensures that validation logic (like auto-setting save_unfull_chunk for PD mode) is properly executed when configs are updated from env vars.