From b942bcd7988365f2ee97d1426ad817f76c6f61ef Mon Sep 17 00:00:00 2001 From: Ian Rodney Date: Mon, 22 Jun 2020 15:02:27 -0700 Subject: [PATCH] [Tune] remove whitelist from deep_copy (#8997) --- python/ray/tune/utils/util.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/python/ray/tune/utils/util.py b/python/ray/tune/utils/util.py index 7e6e8125e..47af14d50 100644 --- a/python/ray/tune/utils/util.py +++ b/python/ray/tune/utils/util.py @@ -154,26 +154,26 @@ def merge_dicts(d1, d2): def deep_update(original, new_dict, new_keys_allowed=False, - whitelist=None, + allow_new_subkey_list=None, override_all_if_type_changes=None): """Updates original dict with values from new_dict recursively. If new key is introduced in new_dict, then if new_keys_allowed is not True, an error will be thrown. Further, for sub-dicts, if the key is - in the whitelist, then new subkeys can be introduced. + in the allow_new_subkey_list, then new subkeys can be introduced. Args: original (dict): Dictionary with default values. new_dict (dict): Dictionary with values to be updated new_keys_allowed (bool): Whether new keys are allowed. - whitelist (Optional[List[str]]): List of keys that correspond to dict - values where new subkeys can be introduced. This is only at the top - level. + allow_new_subkey_list (Optional[List[str]]): List of keys that + correspond to dict values where new subkeys can be introduced. + This is only at the top level. override_all_if_type_changes(Optional[List[str]]): List of top level keys with value=dict, for which we always simply override the entire value (dict), iff the "type" key in that value dict changes. """ - whitelist = whitelist or [] + allow_new_subkey_list = allow_new_subkey_list or [] override_all_if_type_changes = override_all_if_type_changes or [] for k, value in new_dict.items(): @@ -187,10 +187,10 @@ def deep_update(original, "type" in value and "type" in original[k] and \ value["type"] != original[k]["type"]: original[k] = value - # Whitelisted key -> ok to add new subkeys. - elif k in whitelist: + # Allowed key -> ok to add new subkeys. + elif k in allow_new_subkey_list: deep_update(original[k], value, True) - # Non-whitelisted key. + # Non-allowed key. else: deep_update(original[k], value, new_keys_allowed) # Original value not a dict OR new value not a dict: