Skip to content

Conversation

Integer003
Copy link
Contributor

@Integer003 Integer003 commented Aug 24, 2025

Description

  • When integrating SwanLab's OpenAPI into MCP Server tools, the get_metrics function frequently throws a list index out of range error, preventing proper functionality. This pull request fixed this bug.

Root Cause Analysis

Through systematic investigation and collaborative debugging, we identified the following error chain:

  1. Immediate Cause: Line 135 in swanlab/api/experiment.py attempts to access [0] from an empty list
    resp.data = list(resp.data.values())[0]  # Line 135
  2. Underlying Cause: Line 131 returns an empty response (resp.data is empty)
    resp = self.http.post("/house/metrics/summaries", data=[data], params={})  # Line 131
  3. Root Cause: The HTTP request returns empty results due to incorrect field naming in the data parameter format

Closes: #1244

- Fix field name mismatch in experiment summary API
- Change rootExperimentId/rootProjectId to rootExpId/rootProId
- Correct parameter order in get_summary method
@Integer003 Integer003 changed the title fix(api): correct root experiment and project field names fix(api): fix method get_summary in class OpenApi Aug 24, 2025
@Zeyi-Lin
Copy link
Member

Hey, @kites262 , can you take a look at this PR?

@kites262
Copy link
Member

Hey, @kites262 , can you take a look at this PR?

sure

@kites262 kites262 self-assigned this Aug 25, 2025
Copy link
Member

@kites262 kites262 left a comment

Choose a reason for hiding this comment

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

ACK

@Zeyi-Lin Zeyi-Lin merged commit 761e2a0 into SwanHubX:main Aug 25, 2025
5 checks passed
@Integer003
Copy link
Contributor Author

Acknowledgements: @illusionsin30

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.

[BUG] 在使用SwanLab的OpenAPI时,get_metrics函数频繁抛出list index out of range错误,导致无法正常获取实验指标数据
3 participants