Skip to content

feat: collect system metadata and requirements on start - #1528

Merged
SAKURA-CAT merged 3 commits into
mainfrom
feat/environment
Mar 31, 2026
Merged

SAKURA-CAT merged 3 commits into
mainfrom
feat/environment

Conversation

@SAKURA-CAT

Copy link
Copy Markdown
Member

接入系统信息采集

On Run startup, collect system environment and hardware info via system.new(), write metadata/requirements/conda files with safe_write and emit corresponding events (MetadataEvent, RequirementsEvent, CondaEvent). Move background consumer start to after initial collection and bind config as before. Add system module that aggregates git/runtime/conda/requirements and hardware (Apple/CPU/Memory) into a SystemEnvironment, and provide MetadataSnapshot.del_hardware to drop hardware when disabled. Make vendor get() methods static and update protocol typings accordingly. Harden requirements detection by using _try_run to handle missing executables and raise if no method succeeds.
@SAKURA-CAT SAKURA-CAT self-assigned this Mar 31, 2026
@SAKURA-CAT SAKURA-CAT added the 💪 enhancement New feature or request label Mar 31, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements system information and hardware metadata collection during run initialization, introducing new event types for Conda, Metadata, and Requirements. It refactors hardware vendor classes to use static methods and enhances the environment requirement gathering process. Review feedback suggests optimizing timestamp object reuse and utilizing Pydantic's model_copy for cleaner object updates.

Comment thread swanlab/sdk/internal/run/__init__.py
Comment thread swanlab/sdk/typings/run/system/__init__.py Outdated
Add typing.Optional import and replace the PEP 604 union annotation with Optional[subprocess.CompletedProcess] for the _try_run return type. This preserves compatibility with Python versions that don't support the '|' union operator and does not change runtime behavior.
Avoid repeated Timestamp instantiation in run initialization by reusing a single Timestamp when emitting metadata/requirements/conda events. Update MetadataSnapshot.del_hardware to use model_copy(update={"hardware": None}) (Pydantic v2-friendly and respects frozen config). Remove an unused test package init and add a comprehensive end-to-end test suite for system hardware collection covering platforms, settings gating, error handling, and data consistency.
@SAKURA-CAT
SAKURA-CAT merged commit acdaedd into main Mar 31, 2026
18 checks passed
@SAKURA-CAT
SAKURA-CAT deleted the feat/environment branch March 31, 2026 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💪 enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant