Fix: Handle null turbo_controller gracefully - #1
Open
jasonstjohn wants to merge 1 commit into
Open
Conversation
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.
Fix: Handle null turbo_controller gracefully
Problem
When using a tuning template with
turbo_controller: null(a valid configuration), Badger generates repeated warnings:The double space in the warning ("for in") indicates that an empty string is being passed to the logger.
Root Cause
In
badger/gui/components/pydantic_editor.py, theinitialize_special_fieldmethod handlesturbo_controllerandnumerical_optimizeras special fields that can have sub-classes (e.g., different turbo controller implementations).When
turbo_controller: nullis in the YAML configuration:defaults.get('turbo_controller')returnsNoneNone)special_item_dict = {}unconditionallynameto be set to"null"(from the empty dict fallback)update_params_from_generator_classis called withname="null"get_compatible_classcannot find a class named "null" and logs the warningThe issue is that the code didn't distinguish between:
null(should be treated as valid, no sub-class to instantiate)Solution
Added an
elsebranch to handle the case whenspecial_item_dict is Nonebut the field does exist in defaults (meaning it's explicitly set to null):When the field is explicitly null:
update_params_from_generator_classTesting
turbo_controller: nullFiles Changed
badger/gui/components/pydantic_editor.py(lines 762-774)