7
7
@Description:
8
8
与Key相关的回调函数触发时的模型
9
9
"""
10
- from typing import Union , Optional , Dict , List , Literal
11
- from swankit .core import ChartType , ParseErrorInfo , MediaBuffer
10
+ from typing import Union , Optional , Dict , List , Literal , Tuple , TypedDict
11
+
12
+ from swankit .core import ChartType , ParseErrorInfo , MediaBuffer , ChartReference
12
13
from urllib .parse import quote
13
14
import os
14
15
16
+ ColumnClass = Literal ["CUSTOM" , "SYSTEM" ]
17
+ SectionType = Literal ["PINNED" , "HIDDEN" , "PUBLIC" , "SYSTEM" ]
18
+ YRange = Optional [Tuple [Optional [float ], Optional [float ]]]
19
+
20
+
21
+ class ColumnConfig (TypedDict ):
22
+ """
23
+ 列信息配置
24
+ """
25
+
26
+ y_range : YRange
27
+
15
28
16
29
class ColumnInfo :
17
30
"""
@@ -21,22 +34,23 @@ class ColumnInfo:
21
34
def __init__ (
22
35
self ,
23
36
key : str ,
24
- key_id : str ,
25
- key_name : str ,
26
- key_class : Literal [ "CUSTOM" , "SYSTEM" ] ,
37
+ kid : str ,
38
+ name : str ,
39
+ cls : ColumnClass ,
27
40
chart_type : ChartType ,
28
- chart_reference : Literal [ "step" , "time" ] ,
41
+ chart_reference : ChartReference ,
29
42
section_name : Optional [str ],
43
+ section_type : SectionType ,
30
44
section_sort : Optional [int ] = None ,
31
45
error : Optional [ParseErrorInfo ] = None ,
32
- config : Optional [Dict ] = None ,
46
+ config : Optional [ColumnConfig ] = None ,
33
47
):
34
48
"""
35
49
生成的列信息对象
36
- :param key: 生成的列名称
37
- :param key_id : 当前实验下,列的唯一id,与保存路径等信息有关
38
- :param key_name: key的别名
39
- :param key_class : 列的类型,CUSTOM为自定义列,SYSTEM为系统生成列
50
+ :param key: 生成的列名称,作为索引键值
51
+ :param kid : 当前实验下,列的唯一id,与保存路径等信息有关,与云端请求无关
52
+ :param name: 列的别名
53
+ :param cls : 列的类型,CUSTOM为自定义列,SYSTEM为系统生成列
40
54
:param chart_type: 列对应的图表类型
41
55
:param chart_reference: 这个列对应图表的参考系,step为步数,time为时间
42
56
:param section_name: 列的组名
@@ -45,18 +59,19 @@ def __init__(
45
59
:param config: 列的额外配置信息
46
60
"""
47
61
self .key = key
48
- self .key_id = key_id
49
- self .key_name = key_name
50
- self .key_class = key_class
62
+ self .kid = kid
63
+ self .name = name
64
+ self .cls = cls
51
65
52
66
self .chart_type = chart_type
53
67
self .chart_reference = chart_reference
54
68
55
69
self .section_name = section_name
56
70
self .section_sort = section_sort
71
+ self .section_type = section_type
57
72
58
73
self .error = error
59
- self .config = config if config is not None else {}
74
+ self .config = config
60
75
61
76
@property
62
77
def got (self ):
@@ -124,7 +139,7 @@ def __init__(
124
139
self .metric_summary = metric_summary
125
140
self .metric_step = metric_step
126
141
self .metric_epoch = metric_epoch
127
- _id = self .column_info .key_id
142
+ _id = self .column_info .kid
128
143
self .metric_file_path = None if self .is_error else os .path .join (swanlab_logdir , _id , metric_file_name )
129
144
self .summary_file_path = None if self .is_error else os .path .join (swanlab_logdir , _id , self .__SUMMARY_NAME )
130
145
self .swanlab_media_dir = swanlab_media_dir
0 commit comments