Skip to content

feat: openapi cli#1562

Open
Nexisato wants to merge 43 commits intomainfrom
feat/open-api-cli
Open

feat: openapi cli#1562
Nexisato wants to merge 43 commits intomainfrom
feat/open-api-cli

Conversation

@Nexisato
Copy link
Copy Markdown
Contributor

Description

#1547 拆分

  • SwanLab OpenAPI 接入
  • 支持通过 swanlab api [project/run/..]SwanLab.Api() 双格式调用

Copy link
Copy Markdown
Contributor

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

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 introduces a comprehensive API client layer and a corresponding CLI interface for SwanLab. It includes a base entity class for handling HTTP requests safely, a set of type definitions for various API resources (experiments, projects, users, etc.), and utility functions for data transformation. The CLI is expanded with an api command group to allow direct interaction with these resources. Feedback focuses on correcting typos in type definitions and file headers, ensuring all CLI subcommands are properly imported and registered, and removing redundant logic in the API response handling.

Comment thread swanlab/api/typings/user.py Outdated
Comment thread swanlab/api/typings/selfhosted.py
Comment thread swanlab/cli/api/__init__.py
Comment thread swanlab/cli/api/__init__.py
Comment thread swanlab/api/typings/common.py Outdated
@Nexisato Nexisato force-pushed the feat/open-api-cli branch from 95c68d7 to 4806400 Compare April 22, 2026 02:52
@Nexisato Nexisato self-assigned this Apr 22, 2026
@Nexisato Nexisato added the 💪 enhancement New feature or request label Apr 23, 2026
@Nexisato
Copy link
Copy Markdown
Contributor Author

Nexisato commented Apr 24, 2026

#1571

  • filter JSON DSL 对用户而言存在一定的上手门槛,此分支以外考虑加一个支持运算符重载的 pr (但是在 cli 模式下需要兼容两种查询语言,待定
    Usage::

        from swanlab.api import FilterOperation as FOP

        runs = project.runs(filters=[
            FOP.state == "FINISHED",
            FOP.createdAt >= "2025-03-25",
            FOP.createdAt <= datetime(2025, 3, 25, 23, 59, 59),
            FOP("lr", type="CONFIG") >= 0.1,
            FOP.state.in_("RUNNING", "FINISHED"),
        ])

    Attribute access (``F.state``) auto-detects STABLE keys.
    For CONFIG / SCALAR fields use call syntax: ``F("key", type="CONFIG")``.

或者按照原本的运算符扩展

@Nexisato Nexisato force-pushed the feat/open-api-cli branch from ca80b03 to d9c4472 Compare April 24, 2026 15:42
@Nexisato Nexisato force-pushed the feat/open-api-cli branch from 77e4b98 to 311e910 Compare April 25, 2026 15:13
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