Common
Common Utils
- the_utils.common.format_result(dataset: str, model: str, source: str | None = None, sort_kw: bool = False, timezone='Asia/Shanghai', **kwargs) Dict [source]
format results.
- Parameters:
dataset (str) – dataset name.
model (str) – model name.
source (str, optional) – data source. Defaults to None.
sort_kw (bool, optional) – sort the kwargs with lowercase. Defaults to False.
timezone (str, optional) – timezone. Defaults to “Asia/Shanghai”.
- Returns:
results dict.
- Return type:
Dict
- the_utils.common.get_str_time(timezone='Asia/Shanghai')[source]
Return localtime in the format of %Y-%m-%d-%H:%M:%S.
- the_utils.common.format_value(value) Any [source]
Return number as string with comma split.
- Parameters:
value (int) – number.
- Returns:
string of the number with comma split.
- Return type:
str
- the_utils.common.tab_printer(args: Dict, thead: List[str] | None = None, cols_align: List[str] | None = None, cols_valign: List[str] | None = None, cols_dtype: List[str] | None = None, sort: bool = True, verbose: bool | int = True) None [source]
Function to print the logs in a nice tabular format.
- Parameters:
args (Dict) – value dict.
thead (List[str], optional) – table head. Defaults to None.
cols_align (List[str], optional) – horizontal alignment of the columns. Defaults to None.
cols_valign (List[str], optional) – vertical alignment of the columns. Defaults to None.
cols_dtype (List[str], optional) – value types of the columns. Defaults to None.
sort (bool, optional) – whether to sort the keys. Defaults to True.
- Returns:
table string to print.
- Return type:
str