Build metric given metric_name and field. Args: metric_name (str | dict): The metric name or metric config dict. field (str, optional): The field of this metric, default value: 'default' for all fields. default_args (dict, optional): Default initialization arguments.
(metric_cfg: Union[str, Dict],
field: str = default_group,
default_args: dict = None)
| 82 | |
| 83 | |
| 84 | def build_metric(metric_cfg: Union[str, Dict], |
| 85 | field: str = default_group, |
| 86 | default_args: dict = None): |
| 87 | """ Build metric given metric_name and field. |
| 88 | |
| 89 | Args: |
| 90 | metric_name (str | dict): The metric name or metric config dict. |
| 91 | field (str, optional): The field of this metric, default value: 'default' for all fields. |
| 92 | default_args (dict, optional): Default initialization arguments. |
| 93 | """ |
| 94 | if isinstance(metric_cfg, Mapping): |
| 95 | assert 'type' in metric_cfg |
| 96 | else: |
| 97 | metric_cfg = ConfigDict({'type': metric_cfg}) |
| 98 | return build_from_cfg( |
| 99 | metric_cfg, METRICS, group_key=field, default_args=default_args) |
no test coverage detected
searching dependent graphs…