MCPcopy Create free account
hub / github.com/InternLM/InternBootcamp / _transform

Function _transform

internbootcamp/utils/data_postprocess.py:830–846  ·  view source on GitHub ↗
(data: Dict[str, Any])

Source from the content-addressed store, hash-verified

828 return value
829
830 def _transform(data: Dict[str, Any]) -> Dict[str, Any]:
831 result = {}
832 for output_key, config in transform_dict.items():
833 if callable(config):
834 # 自定义函数
835 result[output_key] = config(data)
836 elif isinstance(config, tuple):
837 # (路径, 默认值)
838 path, default = config
839 result[output_key] = _get_nested_value(data, path, default)
840 elif isinstance(config, str):
841 # 字段路径
842 result[output_key] = _get_nested_value(data, config)
843 else:
844 # 直接使用配置值
845 result[output_key] = config
846 return result
847
848 return _transform
849

Calls 1

_get_nested_valueFunction · 0.85

Tested by

no test coverage detected