Closed zhiruiluo closed 1 year ago
WIP
Hi @lebrice, Sorry for letting you wait too long.
Here is the updating:
Hi @lebrice, Here are some updates so far:
I would appreciate any further feedback or suggestions for improvement that you may have. Thank you.
This PR is to add the
replace_selections
function that replaces some values in a dataclass and replaces dataclass type in nested union of dataclasses or subgroups.simple_parsing.replace_selections
function support replacingeplaces dataclass type in nested union of dataclasses or subgroups in addition tosimple_parsing.replace
#212.replace_selections(obj: DataclassT, changes_dict: dict[str, Any] | None = None, selections: dict[str, Key | DataclassT] | None = None, **changes) -> DataclassT:
simple_replace.replace
, this callsreplace_selected_dataclass
before callingsimple_parsing.replace
.replace_selected_dataclass
selections
is in flat format, e.g. {"ab_or_cd": 'cd', "ab_or_cd.c_or_d": 'd'}Key
of subgroups, dataclass type, and dataclass instance.Open question:
simple_parsing.replace_selections
andsimple_parsing.replace
?Examples