Skip to content

Conversation

kites262
Copy link
Member

@kites262 kites262 commented May 8, 2025

Description

    获取项目下的实验列表(分页)

    Args:
        project (str): 项目名
        username (Optional[str]): 工作空间名, 默认为用户个人空间
        page (int): 页码, 默认为1
        size (int): 每页大小, 默认为10

    Returns:
        dict: 实验列表分页信息的字典, 包含以下字段:
            - total (int): 实验总数
            - exps (list[dict]): 实验列表, 每个实验包含以下字段:
                - cuid (str): 实验cuid
                - name (str): 实验名称
                - description (str): 实验描述
                - state (str): 实验状态, 为 'FINISHED' 或 'RUNNING'
                - show (bool): 显示状态
                - createdAt (str): 创建时间, 格式如 '2024-11-23T12:28:04.286Z'
                - finishedAt (str): 完成时间(若有), 格式同上
                - user (dict): 实验创建者的 'username' 与 'name'
                - profile (dict): 实验配置文件, 包含以下字段:
                    - config (dict): 实验的配置参数
                    - metadata (dict): 实验的元数据
                    - requirements (str): 实验的依赖项
                    - conda (str): 实验的 Conda 环境信息

        若请求失败, 将返回包含以下字段的字典:
            - code (int): HTTP 错误代码
            - message (str): 错误信息

@kites262 kites262 requested a review from Copilot May 8, 2025 08:31
Copy link

@Copilot Copilot AI left a 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 a new API endpoint to retrieve a paginated list of experiments for a project and updates related API methods and tests.

  • Adds the get_project_exps function in OpenApi and ExperimentAPI.
  • Updates documentation and parameter names to clarify that experiment identifiers are CUIDs.
  • Introduces a new unit test for the project experiments retrieval endpoint.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
test/unit/api/openapi/test_experiment.py Adds a test case for the new get_project_exps endpoint.
swanlab/api/openapi/main.py Updates API method parameter names and docstrings.
swanlab/api/openapi/experiment.py Implements the get_project_exps API and adjusts field mappings.
swanlab/api/openapi/base.py Simplifies HTTP method wrappers by adding default parameters.
Comments suppressed due to low confidence (1)

test/unit/api/openapi/test_experiment.py:68

  • [nitpick] Consider expanding the test assertions to validate the full response schema (including 'total' and the structure of each experiment) when 'exps' is present, rather than only checking for existence or a 404 error.
assert isinstance(res, dict)

@kites262 kites262 merged commit 29c2c92 into feature/openapis May 8, 2025
5 checks passed
@kites262 kites262 deleted the feature/openapi/get-project-exps branch May 8, 2025 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant