feat: add created at post request for ch cluster - #1738
Merged
Conversation
SAKURA-CAT
requested changes
Aug 18, 2026
SAKURA-CAT
requested changes
Aug 18, 2026
SAKURA-CAT
previously approved these changes
Aug 18, 2026
SAKURA-CAT
force-pushed
the
feat/openapi-with-createtat
branch
from
August 18, 2026 16:22
def5e94 to
a04865e
Compare
The backend does not return `createdAt` when creating a new experiment, so use the client-provided timestamp. When resuming an existing experiment, fetch the actual creation time from the run endpoint. Update type signatures accordingly.
SAKURA-CAT
reviewed
Aug 18, 2026
SAKURA-CAT
left a comment
Member
There was a problem hiding this comment.
审核结论: 评论
上一轮阻塞项已全部解决,剩余为非阻塞 finding;建议 CI 转绿、PR 描述修正后再合并。
本次 PR 解决的问题
House 指标查询接口新增必填 createdAt(10 位 Unix 秒)作为 ClickHouse 数据入库时间的包含式下界,裁剪扫描范围避免慢查询;新增共享工具 parse_timestamp_s() 统一归一化秒/毫秒时间戳与 ISO 8601 字符串。
审核范围
- 公共 API 与类型兼容:
ApiExperimentType.createdAt(optional)、InitExperimentType.createdAt(required),无顶层 API 变更 - Run 生命周期与运行时组件: resume/sync lane 的 summary 查询接入
- Record、Core 与传输:
core.py/sync.py仅透传createdAt,不改批次与重试逻辑 - 配置、认证与 HTTP 客户端:
create_or_resume_experiment的 GET 回退走既有 client,无凭据暴露 - Public API 与 CLI:
swanlab/api/**、swanlab/cli/api/**全部查询 lane 注入createdAt - 媒体、集成与插件: 无变更
- Protobuf、构建与依赖: 无变更
- 安全、性能与跨平台兼容: Py3.9 兼容(
datetime.fromisoformat未用Z直解),无敏感数据泄露;resume 额外 GET 已缓解 - 测试与验证: 新增
TestCreatedAt、TestParseTimestampS;sync fixture 已修复
未挂行发现
建议: PR 描述与实现不符——描述称“None/空串/无法解析时返回 0”、“House 未更新时 createdAt 被静默丢弃无影响”,实际 parse_timestamp_s 抛 ValueError(测试 test_payload_raises_when_created_at_missing 锁定硬失败设计);描述提到的 swanlab/api/utils.py 不存在(实际 swanlab/utils/time/__init__.py)。建议合并前修正描述,避免误导后续维护者。
说明: 查询 lane 在未返回 createdAt 的旧自部署后端上会使 metrics()/summary()/logs() 等抛错;PR Notes 已声明“House 更新则必须更新 SDK”,视为有意决策。resume 额外 GET 的长期方案已由 SwanHubX/SwanLab-Server#1090 跟踪。
验证
SAKURA-CAT
approved these changes
Aug 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
House 指标查询接口现在要求必须携带实验的
createdAt(10 位 Unix 秒时间戳),并以createdAt >= toDateTime(<createdAt>)作为 ClickHouse 数据入库时间的包含式单边下界,用于裁剪扫描范围、避免每次查询重复扫描冷层数据。Changes
新增工具模块
swanlab/utils/time(查询 API lane 与运行时 SDK lane 共用):parse_timestamp_s():将 ISO 8601 字符串(含/不含时区)、秒级(10 位)/毫秒级(13 位)时间戳统一归一化为 10 位 Unix 秒None/ 空串 / 无法解析 / 非正数 / 越界时抛出ValueError,不做默认值回退,避免 House 退化为全历史扫描(慢查询)查询 lane(
swanlab/api/**、swanlab/cli/api/**):Metric/Metrics/Summary/Key/Column/Columns构造参数created_at必传(无默认值)createdAtSeries构造时校验每个 experiment ref 必须携带非零createdAt,缺失即抛错运行时 lane(
swanlab/sdk/internal/core_python/**):create_or_resume_experiment()确保createdAt总是被填充:createdAt:直接使用(对接 SwanHubX/SwanLab-Server#1090)GET /runs/{cuid}获取ValueError(提示升级 swanlab-server)get_experiment_summary()以createdAt作为查询下界Notes
createdAt为强制携带:后端未返回该字段时显式报错,而非静默降级为无下界查询createdAt后可消除 resume 场景的额外 GET:SwanHubX/SwanLab-Server#1090