-
Notifications
You must be signed in to change notification settings - Fork 142
Feat/record proto #1091
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/record proto #1091
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces new proto definitions for metric, experiment, and project records, along with updated build scripts, go.mod dependency changes, and expanded tests to validate JSON serialization and yRange parsing.
- Adds new .proto files and corresponding Python and Go generated code
- Implements a parser in Go with unit tests for handling yRange conversion and enum validation
- Updates build and CI configuration files and documentation for the core module
Reviewed Changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
swanlab/proto/record/v1/metric_pb2.pyi | Added view of generated type definitions for metric records |
swanlab/proto/record/v1/metric_pb2.py | Generated Python file for metric proto changes |
swanlab/proto/record/v1/metric.proto | New proto definitions for runtime, column, media, scalar and log records |
swanlab/proto/record/v1/experiment_pb2.pyi | Added new experiment proto type definitions |
swanlab/proto/record/v1/experiment_pb2.py | Generated Python file for experiment proto changes |
swanlab/proto/record/v1/experiment.proto | New proto definitions for project and experiment records |
script/build_proto.py | Updated build instructions to include gRPC tools installation |
core/pkg/pb/*.go | Updated Go generated files (experiment, common, collector service) |
core/internal/api/parse.go | Introduced a Parser for proto-to-JSON conversion and yRange handling |
core/internal/api/parse_test.go | Added unit tests to validate yRange serialization and parser functionality |
core/internal/api/api.go | Minor documentation update in file header |
core/go.mod | Updated dependencies and added indirect modules |
core/README.md | Updated file template documentation |
.github/workflows/test-core.yml | Enhanced CI workflow with additional testing and module verification |
Comments suppressed due to low confidence (2)
core/internal/api/parse.go:1
- The file header title 'send.go' does not match the actual file name 'parse.go'. Consider updating the header to reflect the correct filename for clarity.
// @Title send.go
core/internal/api/parse_test.go:70
- [nitpick] Consider replacing 'string(rune(rand.Intn(1000)))' with 'strconv.Itoa(rand.Intn(1000))' for a clearer and more idiomatic conversion of an integer to a string.
record.ChartIndex: "test-chart-index" + string(rune(rand.Intn(1000))),
10281b3
to
485ae66
Compare
616e996
to
74b5b13
Compare
74b5b13
to
5e1eac9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good job! 👍
* feat: init go project (#1064) * fix: license use symlink (#1067) * Feature/protobuf: hello-word (#1074) * feat: init go project (#1064) * feat: add proto and grpc * feat: add proto build script * fix: golangci lint * feat: support auto or specify select port * chore: license * chore: add .golangci.yml * fix: use log/slog instead of log * chore: del core vendor --------- Co-authored-by: Kang Li <79990647+SAKURA-CAT@users.noreply.github.com> * feat: impl health checker and init data collector (#1077) * feat: impl health checker and init data collector * chore: change module name --------- Co-authored-by: KAAANG <79990647+SAKURA-CAT@users.noreply.github.com> * Feat/record proto and column parser (#1091) Co-authored-by: kaikai <2837968358@qq.com> * fix: import module and typo --------- Co-authored-by: Kaikai <98205900+Kaikaikaifang@users.noreply.github.com> Co-authored-by: kaikai <2837968358@qq.com>
Description
for #1063
列的枚举定义
在column的proto中,我们定义了以下枚举:
其中除了 列type为必传参数以外,其他为可选,这意味着只有列的枚举0值被设置为UNKNOWN:
其他的枚举中0为默认值(有效值),这样方便测试,减少繁琐的计算。
yRange解析测试
在go中要实现
null
和int
共存是一件很麻烦的事情,我们通过使用指针实现了这一点,从而在json序列化时支持类似[null, int]
的格式。在这里需要直接访问protobuf结构体的值,以防Get函数在空指针时自动设置默认空值——但是在linter规则中这不允许,因此我们通过注释显式告诉linter:
Record 包装message
在保存备份日志时所有message都保存在同一份文件中,因此需要一个统一的message包装器来打包、标识不同类型的message——我们称之为
Record
: