Skip to content

Commit

Permalink
Reapply "update:callback (#66)" (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
SAKURA-CAT authored Dec 5, 2024
1 parent f4cd4a1 commit fd6c783
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 12 additions & 8 deletions swanboard/callback.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from swankit.callback import SwanKitCallback, ColumnInfo
from swankit.callback import SwanKitCallback
from swankit.callback.models import ColumnInfo
from .db.models import *
from .db import add_multi_chart, connect, NotExistedError, ExistedError, ChartTypeError
from typing import Tuple, Optional
Expand Down Expand Up @@ -75,19 +76,22 @@ 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.cls != "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,
config=column_info.config,
type=chart_type,
reference=column_info.chart_reference.lower(),
)
# 创建命名空间,如果命名空间已经存在,会抛出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 @@ -97,8 +101,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.kid,
)
# 添加一条source记录
error = None
Expand Down
2 changes: 1 addition & 1 deletion swanboard/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swanboard",
"version": "0.1.4-alpha",
"version": "0.1.7-beta.1",
"description": "Dashboard for Swanlab",
"python": "true"
}

0 comments on commit fd6c783

Please sign in to comment.