Repository navigation
feat: add python client skeleton - #1803
Merged
Merged
Conversation
- add fixed handshake constants shared by client modules - add CoreGoError with stage/reason and gRPC status-name mapping - parse port-file v1 with Go portinfo parity - validate pid and unix/tcp endpoint ownership
- create private 0700 runtime dirs under the system temp root - spawn swanlab-core with port-file/parent-pid only and sanitized env - poll endpoint, classify early exit codes and validate ownership - reap with wait -> terminate -> kill and keep bounded stderr
- lazily import grpcio and wait for channel readiness - map gRPC statuses once and preserve UNIMPLEMENTED details - attach session_id to every run-level request - convert success=false responses into protocol errors
- add RpcChannelType Protocol under swanlab.sdk.typings.core_go - switch core_go modules to absolute imports and drop the rpc re-export - report missing grpcio as GRPC_UNAVAILABLE instead of leaking ImportError - skip POSIX mode/uid checks on Windows runtime dirs
- add CoreLauncher as the sole owner of runtime, process and channel - validate binary before creating runtime and clean up on any start failure - make close/abort idempotent and guard fork children via pkg.fork - reuse validate_core_binary and cover launcher orchestration with unit tests
- add CoreGo state machine and single session_id binding - start via launcher, SpinupService and DeliverRunStart - forward upserts and surface UNIMPLEMENTED once without fallback - map finish/stats/confirm and keep close/abort idempotent - return a NullCoreProtocol-based detached stub for fork children
Nexisato
marked this pull request as ready for review
October 28, 2026 02:42
Resolve core binary paths before launching from the runtime directory, and use safe.block to contain cleanup failures during teardown and channel close. Add a regression test for relative binary paths.
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.
概述
Python SDK 侧调用
swanlab-core(Go)的客户端骨架:拉起进程、发现端点、建立 gRPC 通道,完成握手与生命周期 RPC,并以CoreGo实现CoreProtocol。依赖 #1776。代码结构
启动与关闭
行为要点
NEW → STARTING → RUNNING → FINISHED → CLOSED,启动失败走ABORTING;close()/abort()幂等。CoreGo绑定一个session_id,所有 run 级 RPC 显式携带;多 run 由多个CoreGo表达。upsert_*返回UNIMPLEMENTED,客户端记录一次 warning 后不重试、不改写、不回退CorePython。CoreGo当前只实现online;local/offline返回MODE_UNSUPPORTED,disabled为 no-op。CoreProtocol与CorePython的四种模式不变。core.fork()返回_DetachedCoreGo(继承NullCoreProtocol),不持有父进程的 launcher / channel / session,调用返回FORK_UNSUPPORTED,不影响父 Core;仅覆盖显式os.fork(),macOS 默认spawn需在子进程重新swanlab.init()。边界
create_core()未改动,生产路径仍走CorePython;CoreEnum.CORE→CoreGo的切换在后续切片。测试
tests/unit/sdk/internal/core_go/覆盖发现、进程、RPC、launcher 与错误映射,109 passed。pytest tests/unit:2138 passed / 21 skipped;basedpyright0 errors;ruff check/ruff format --check通过。UNIMPLEMENTED、重复 close。合并顺序
1803 → 1776 (
feat/gateway-starter) →feature/core