Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Optimizer] properly handle multiple and single options #2249

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

techfreaque
Copy link
Contributor

You will need to adapt private optimizer code:
for ConfigTypes.MULTIPLE_OPTIONS to work properly (multiple-options user inputs), the strategy design config generated by the frontend needs to pass the config "type": ConfigTypes.MULTIPLE_OPTIONS.value (config_element[self.CONFIG_TYPE] == ConfigTypes.MULTIPLE_OPTIONS.value)

all other ConfigTypes are supported to set via "type" as well, but should not be saved/sent via api as we can infer them still

):
for combineable_value in config_element_values:
if combineable_value not in parent_values:
new_parent_values = parent_values + [combineable_value]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better if we have something like this instead?

def _generate_possible_multiple_options_values(
    self,
    possible_values: list,
    config_element_values,
    parent_values: Optional[list] = None,
):
    if parent_values is None:
        parent_values = []
    # rest of the code...

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a mutable default argument like parent_values=[] can lead to unintended side effects because the same list instance is shared across all calls to the function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ruidazeng
ah I see thanks, I changed it

@techfreaque techfreaque force-pushed the optimizer_fixes branch 2 times, most recently from 76085a5 to 96ceb59 Compare November 11, 2024 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants