Skip to content

Commit

Permalink
update:callback (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
SAKURA-CAT authored Oct 20, 2024
1 parent 08e22ca commit 9a7b851
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions swanboard/callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,23 @@ def on_log(self):
raise KeyboardInterrupt("The experiment has been stopped by the user")

def on_column_create(self, column_info: ColumnInfo):

if column_info.key_class != "CUSTOM":
return # 屏蔽系统生成的指标
chart_type = column_info.chart_type.value.chart_type
# 创建Chart
chart = Chart.create(
column_info.key,
experiment_id=self.exp,
type=column_info.chart.value.chart_type,
reference=column_info.reference,
type=chart_type,
reference=column_info.chart_reference,
config=column_info.config,
)
# 创建命名空间,如果命名空间已经存在,会抛出ExistedError异常,捕获不处理即可
# 需要指定sort,default命名空间的sort为0,其他命名空间的sort为None,表示默认添加到最后
namespace = column_info.namespace
namespace = column_info.section_name
try:
n = Namespace.create(name=namespace, experiment_id=self.exp.id, sort=column_info.sort)
n = Namespace.create(name=namespace, experiment_id=self.exp.id, sort=column_info.section_sort)
swanlog.debug(f"Namespace {namespace} created, id: {n.id}")
except ExistedError:
n: Namespace = Namespace.get(name=namespace, experiment_id=self.exp.id)
Expand All @@ -94,8 +98,8 @@ def on_column_create(self, column_info: ColumnInfo):
tag: Tag = Tag.create(
experiment_id=self.exp.id,
name=column_info.key,
type=column_info.chart.value.chart_type,
folder=column_info.id,
type=chart_type,
folder=column_info.key_id,
)
# 添加一条source记录
error = None
Expand Down

0 comments on commit 9a7b851

Please sign in to comment.