Obtains the named parameters for golden config test. Args: module: A module. match_by_name: A string which will be used for selecting config_names for golden config. attr_name: The attribute name to get the named configs from module. data_dir: The data_dir to set
(
module: ModuleType,
*,
match_by_name: Optional[str] = None,
attr_name: str = "named_trainer_configs",
data_dir: str = "$DATA_DIR",
)
| 42 | |
| 43 | |
| 44 | def named_parameters( |
| 45 | module: ModuleType, |
| 46 | *, |
| 47 | match_by_name: Optional[str] = None, |
| 48 | attr_name: str = "named_trainer_configs", |
| 49 | data_dir: str = "$DATA_DIR", |
| 50 | ) -> list[tuple[str, ModuleType, str, TrainerConfigFn]]: |
| 51 | """Obtains the named parameters for golden config test. |
| 52 | |
| 53 | Args: |
| 54 | module: A module. |
| 55 | match_by_name: A string which will be used for selecting config_names for golden config. |
| 56 | attr_name: The attribute name to get the named configs from module. |
| 57 | data_dir: The data_dir to set when fetching the configs. |
| 58 | |
| 59 | Returns: |
| 60 | A list of |
| 61 | - a string with {module}.{name} |
| 62 | - a ModuleType module |
| 63 | - a config name |
| 64 | - the trainer config for the module.config_name. |
| 65 | """ |
| 66 | with set_data_dir(data_dir): |
| 67 | final_named_trainer_configs = {} |
| 68 | named_trainer_configs = getattr(module, attr_name)() |
| 69 | if match_by_name: |
| 70 | # If match_by_name is not None, filter config_names based on match_by_name. |
| 71 | for name in named_trainer_configs.keys(): |
| 72 | if re.fullmatch(match_by_name, name): |
| 73 | final_named_trainer_configs[name] = named_trainer_configs[name] |
| 74 | else: |
| 75 | final_named_trainer_configs = named_trainer_configs |
| 76 | return [ |
| 77 | (f"{module.__name__}.{name}", module, name, final_named_trainer_configs[name]) |
| 78 | for name in final_named_trainer_configs.keys() |
| 79 | ] |
| 80 | |
| 81 | |
| 82 | def param_init_debug_string( |
nothing calls this directly
no test coverage detected