MCPcopy Create free account
hub / github.com/apple/axlearn / debug_string

Method debug_string

axlearn/common/config.py:588–614  ·  view source on GitHub ↗

Returns a debug string for the config. Args: kv_separator: The key-value separator. field_separator: The field separator. omit_default_values: A set of default values to omit in debug string. See comments on `to_flat_dict`. Return

(
        self,
        *,
        kv_separator: str = ": ",
        field_separator: str = "\n",
        omit_default_values: Collection[Any] = (None, REQUIRED),
    )

Source from the content-addressed store, hash-verified

586 return attr.evolve(self).set(**kwargs)
587
588 def debug_string(
589 self,
590 *,
591 kv_separator: str = ": ",
592 field_separator: str = "\n",
593 omit_default_values: Collection[Any] = (None, REQUIRED),
594 ) -> str:
595 """Returns a debug string for the config.
596
597 Args:
598 kv_separator: The key-value separator.
599 field_separator: The field separator.
600 omit_default_values: A set of default values to omit in debug string.
601 See comments on `to_flat_dict`.
602
603 Returns:
604 A str separated by `field_separator` where each entry is of form
605 f"{path}{kv_separator}{val}", representing path and value of a leaf config field.
606 """
607 flat_dict = self.to_flat_dict(omit_default_values=omit_default_values)
608
609 def fmt(key: str, val: Any) -> Union[str, tuple[str, str]]:
610 if isinstance(val, (type, types.FunctionType)):
611 val = f"{val.__module__}.{val.__name__}"
612 return f"{key}{kv_separator}{repr(val)}"
613
614 return field_separator.join([fmt(k, v) for k, v in flat_dict.items()])
615
616 def to_flat_dict(self, *, omit_default_values: Collection[Any]) -> dict[str, Any]:
617 """Returns a flattened dict with path -> value mappings.

Callers 15

__str__Method · 0.95
__repr__Method · 0.95
param_init_debug_stringFunction · 0.45
generate_golden_textFunction · 0.45
log_configMethod · 0.45
test_setMethod · 0.45
test_cloneMethod · 0.45
test_value_typesMethod · 0.45
test_nested_configsMethod · 0.45

Calls 3

to_flat_dictMethod · 0.95
joinMethod · 0.80
itemsMethod · 0.80