Skip to content

[feature][for merge][part0] Support terminal-bench-2 - #319

Merged
Keithwwa merged 1 commit into
AISBench:masterfrom
SJTUyh:tb2_part0
Jun 3, 2026
Merged

Keithwwa merged 1 commit into
AISBench:masterfrom
SJTUyh:tb2_part0

Conversation

@SJTUyh

@SJTUyh SJTUyh commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Thanks for your contribution; we appreciate it a lot. The following instructions will make your pull request healthier and help you get feedback more easily. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.
感谢您的贡献,我们非常重视。以下说明将使您的拉取请求更健康,更易于获得反馈。如果您不理解某些项目,请不要担心,只需提交拉取请求并从维护人员那里寻求帮助即可。

PR Type / PR类型

  • Feature(功能新增)
  • Bugfix(Bug 修复)
  • Docs(文档更新)
  • CI/CD(持续集成/持续部署)
  • Refactor(代码重构)
  • Perf(性能优化)
  • Dependency(依赖项更新)
  • Test-Cases(测试用例更新)
  • Other(其他)

Related Issue | 关联 Issue
Fixes #(issue ID / issue 编号) / Relates to #(issue ID / issue 编号)

🔍 Motivation / 变更动机

Please describe the motivation of this PR and the goal you want to achieve through this PR.
请描述您的拉取请求的动机和您希望通过此拉取请求实现的目标。

#314

📝 Modification / 修改内容

Please briefly describe what modification is made in this PR.
请简要描述此拉取请求中进行的修改。

📐 Associated Test Results / 关联测试结果

Please provide links to the related test results, such as CI pipelines, test reports, etc.
请提供相关测试结果的链接,例如 CI 管道、测试报告等。

⚠️ BC-breaking (Optional) / 向后不兼容变更(可选)

Does the modification introduce changes that break the backward compatibility of the downstream repositories? If so, please describe how it breaks the compatibility and how the downstream projects should modify their code to keep compatibility with this PR.
是否引入了会破坏下游存储库向后兼容性的更改?如果是,请描述它如何破坏兼容性,以及下游项目应该如何修改其代码以保持与此 PR 的兼容性。

⚠️ Performance degradation (Optional) / 性能下降(可选)

If the modification introduces performance degradation, please describe the impact of the performance degradation and the expected performance improvement.
如果引入了性能下降,请描述性能下降的影响和预期的性能改进。

🌟 Use cases (Optional) / 使用案例(可选)

If this PR introduces a new feature, it is better to list some use cases here and update the documentation.
如果此拉取请求引入了新功能,最好在此处列出一些用例并更新文档。

✅ Checklist / 检查列表

Before PR:

  • Pre-commit or other linting tools are used to fix the potential lint issues. / 使用预提交或其他 linting 工具来修复潜在的 lint 问题。
  • Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。
  • The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。
  • All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。

After PR:

  • If the modification has potential influence on downstream or other related projects, this PR should be tested with those projects. / 如果此拉取请求对下游或其他相关项目有潜在影响,应在那些项目中测试此 PR。
  • CLA has been signed and all committers have signed the CLA in this PR. / CLA 已签署,且本 PR 中的所有提交者均已签署 CLA。

👥 Collaboration Info / 协作信息

  • Suggested Reviewers / 建议审核人: @xxx
  • Relevant Module Owners / 相关模块负责人: @xxx
  • Other Collaboration Notes / 其他协作说明:

🌟 Useful CI Command / 实用的CI命令

Command / 命令 Introduction / 介绍
/gemini review Performs a code review for the current pull request in its current state by Gemini. / 对当前拉取请求在当前状态下由 Gemini 执行代码审核。
/gemini summary Provides a summary of the current pull request in its current state by Gemini. / 对当前拉取请求在当前状态下由 Gemini 提供摘要。
/gemini help Displays a list of available commands of Gemini. / 显示 Gemini 可用命令的列表。
/readthedocs build Triggers a build of the documentation for the current pull request in its current state by Read the Docs. / 触发当前拉取请求在当前状态下由 Read the Docs 构建文档。

@SJTUyh
SJTUyh temporarily deployed to smoke-test-approval June 3, 2026 03:26 — with GitHub Actions Inactive

@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 introduces the Harbor benchmark integration, adding HarborSummarizer for result aggregation, HarborTask for running evaluation jobs, and an example configuration file. While the implementation is comprehensive, several critical issues were identified in the review: HarborSummarizer contains bugs that will cause crashes, including the use of a non-existent mmengine.utils.TimeStub class, an unsupported csv format in tabulate, and malformed table row construction. Additionally, HarborTask has potential runtime issues, such as overwriting existing OPENAI_API_KEY environment variables, calling signal.signal in potentially non-main threads, and a risk of AttributeError when updating config.verifier.env if it is uninitialized.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +128 to +152
for dataset_abbr, metric in dataset_abbrs:
for model_abbr in self.model_abbrs:
if metric is None:
for k in parsed_results.get(model_abbr, {}).get(dataset_abbr, {}).keys():
row = [dataset_abbr, 'a39421', k, dataset_eval_mode.get(dataset_abbr, 'gen')]
if has_total_count:
row.insert(4, raw_results[model_abbr][dataset_abbr].get('total_count', '-'))
row.append(parsed_results[model_abbr][dataset_abbr][k])
table.append(row)
else:
if dataset_abbr in parsed_results[model_abbr] and metric in parsed_results[model_abbr][dataset_abbr]:
row = [dataset_abbr, 'a39421', metric, dataset_eval_mode.get(dataset_abbr, 'gen')]
if has_total_count:
row.insert(4, raw_results[model_abbr][dataset_abbr].get('total_count', '-'))
row.append(parsed_results[model_abbr][dataset_abbr][metric])
table.append(row)

for sg in self.summary_groups:
for model_abbr in self.model_abbrs:
if sg['name'] in parsed_results[model_abbr]:
row = [sg['name'], sg.get('version', '-'), sg.get('metric', 'naive_average'), dataset_eval_mode.get(sg['name'], 'gen')]
if has_total_count:
row.insert(4, len(sg['subsets']))
row.extend([parsed_results[m].get(sg['name'], {}).get(sg.get('metric', 'naive_average'), '-') for m in self.model_abbrs])
table.append(row)

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.

critical

The current implementation of table row construction loops over self.model_abbrs and appends a single model's score to a new row, then appends that row to the table. However, the table header contains columns for all models. This results in malformed rows where the columns do not align with the header (e.g., a row for the second model will have its score displayed under the first model's column, and the row length will not match the header length). Additionally, the summary groups loop will add duplicate rows for each model that has results. We should construct a single row per metric/summary group and populate the scores for all models in that row.

        for dataset_abbr, metric in dataset_abbrs:
            if metric is None:
                metrics = set()
                for model_abbr in self.model_abbrs:
                    metrics.update(parsed_results.get(model_abbr, {}).get(dataset_abbr, {}).keys())
                for k in sorted(metrics):
                    row = [dataset_abbr, 'a39421', k, dataset_eval_mode.get(dataset_abbr, 'gen')]
                    if has_total_count:
                        total_count = '-'
                        for model_abbr in self.model_abbrs:
                            if dataset_abbr in raw_results.get(model_abbr, {}) and 'total_count' in raw_results[model_abbr][dataset_abbr]:
                                total_count = raw_results[model_abbr][dataset_abbr]['total_count']
                                break
                        row.insert(4, total_count)
                    for model_abbr in self.model_abbrs:
                        row.append(parsed_results.get(model_abbr, {}).get(dataset_abbr, {}).get(k, '-'))
                    table.append(row)
            else:
                if any(dataset_abbr in parsed_results[model_abbr] and metric in parsed_results[model_abbr][dataset_abbr] for model_abbr in self.model_abbrs):
                    row = [dataset_abbr, 'a39421', metric, dataset_eval_mode.get(dataset_abbr, 'gen')]
                    if has_total_count:
                        total_count = '-'
                        for model_abbr in self.model_abbrs:
                            if dataset_abbr in raw_results.get(model_abbr, {}) and 'total_count' in raw_results[model_abbr][dataset_abbr]:
                                total_count = raw_results[model_abbr][dataset_abbr]['total_count']
                                break
                        row.insert(4, total_count)
                    for model_abbr in self.model_abbrs:
                        row.append(parsed_results.get(model_abbr, {}).get(dataset_abbr, {}).get(metric, '-'))
                    table.append(row)

        for sg in self.summary_groups:
            if any(sg['name'] in parsed_results[model_abbr] for model_abbr in self.model_abbrs):
                row = [sg['name'], sg.get('version', '-'), sg.get('metric', 'naive_average'), dataset_eval_mode.get(sg['name'], 'gen')]
                if has_total_count:
                    row.insert(4, len(sg['subsets']))
                row.extend([parsed_results[m].get(sg['name'], {}).get(sg.get('metric', 'naive_average'), '-') for m in self.model_abbrs])
                table.append(row)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

[review] 当前表格行构建的实现方式是循环遍历 self.model_abbrs,并将单个模型的得分添加到新行,然后将该行添加到表格中。然而,表格标题包含所有模型的列。这会导致行格式错误,列与标题不对齐(例如,第二个模型的得分会显示在第一个模型的列下,并且行长度与标题长度不匹配)

summary_dir = osp.join(self.work_dir, 'summary')
mmengine.mkdir_or_exist(summary_dir)

time_str = time_str or mmengine.utils.TimeStub.now().time_str

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.

critical

mmengine.utils does not contain a TimeStub class or attribute. Attempting to call mmengine.utils.TimeStub.now() will raise an AttributeError and crash the summarizer. Use the standard library datetime module instead.

Suggested change
time_str = time_str or mmengine.utils.TimeStub.now().time_str
from datetime import datetime
time_str = time_str or datetime.now().strftime('%Y%m%d_%H%M%S')

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

[review]mmengine.utils 不包含 TimeStub 类或属性。尝试调用 mmengine.utils.TimeStub.now() 将引发 AttributeError 并导致汇总程序崩溃。请改用标准库的 datetime 模块。

Comment on lines +169 to +171
print(f'write csv to {summary_csv}')
with open(summary_csv, 'w', encoding='utf-8') as out:
out.write(tabulate.tabulate(table[1:], headers=table[0], tablefmt='csv'))

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.

critical

tabulate does not support csv as a table format. Attempting to use tablefmt='csv' will raise a ValueError: unknown table format: csv and crash the summarizer. Write the CSV file manually or use a standard CSV writer.

Suggested change
print(f'write csv to {summary_csv}')
with open(summary_csv, 'w', encoding='utf-8') as out:
out.write(tabulate.tabulate(table[1:], headers=table[0], tablefmt='csv'))
print(f'write csv to {summary_csv}')
with open(summary_csv, 'w', encoding='utf-8') as out:
out.write('\\n'.join([','.join(map(str, row)) for row in table]) + '\\n')

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

[review] tabulate 函数不支持 csv 作为表格格式。尝试使用 tablefmt='csv' 会引发 ValueError: unknown table format: csv 错误,并导致汇总程序崩溃。请手动写入 CSV 文件或使用标准 CSV 写入器。

Comment on lines +58 to +62
def _set_api_key(self):
api_key = self.model_cfg.get("api_key")
if api_key is None:
api_key = DEFAULT_FAKE_API_KEY
os.environ["OPENAI_API_KEY"] = api_key

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.

high

If api_key is not specified in model_cfg, the code currently overwrites os.environ["OPENAI_API_KEY"] with DEFAULT_FAKE_API_KEY ("fake_api_key"). This will break evaluations for users who have already set a valid OPENAI_API_KEY in their environment. We should check if the environment variable is already set before defaulting to the fake key.

Suggested change
def _set_api_key(self):
api_key = self.model_cfg.get("api_key")
if api_key is None:
api_key = DEFAULT_FAKE_API_KEY
os.environ["OPENAI_API_KEY"] = api_key
def _set_api_key(self):
api_key = self.model_cfg.get("api_key")
if api_key is None:
api_key = os.environ.get("OPENAI_API_KEY", DEFAULT_FAKE_API_KEY)
os.environ["OPENAI_API_KEY"] = api_key

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

[review] 如果 model_cfg 中未指定 api_key,则当前代码会将 os.environ["OPENAI_API_KEY"] 覆盖为 DEFAULT_FAKE_API_KEY("fake_api_key"))。这将导致已在其环境中设置有效 OPENAI_API_KEY 的用户无法进行评估。我们应该在默认使用伪造密钥之前,检查环境变量是否已设置。

Comment on lines +265 to +269
def _handle_sigterm(signum, frame):
stop_event.set()
raise KeyboardInterrupt

signal.signal(signal.SIGTERM, _handle_sigterm)

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.

high

In Python, signal.signal can only be called from the main thread. If this task is executed in a non-main thread (e.g., as part of a multi-threaded pipeline or background worker), calling signal.signal will raise a ValueError and crash the task. Wrap the call in a try-except ValueError block to make it safe.

Suggested change
def _handle_sigterm(signum, frame):
stop_event.set()
raise KeyboardInterrupt
signal.signal(signal.SIGTERM, _handle_sigterm)
def _handle_sigterm(signum, frame):
stop_event.set()
raise KeyboardInterrupt
try:
signal.signal(signal.SIGTERM, _handle_sigterm)
except ValueError:
pass

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

[review]在 Python 中,signal.signal 只能从主线程调用。如果此任务在非主线程中执行(例如,作为多线程管道或后台工作线程的一部分),调用 signal.signal 将引发 ValueError 并导致任务崩溃。为了安全起见,请将调用包装在 try-except ValueError 代码块中。

Comment on lines +154 to +157
if args.get("verifier_env"):
env_list = args["verifier_env"]
if isinstance(env_list, list):
config.verifier.env.update({k: v for k, v in (e.split("=", 1) for e in env_list if "=" in e)})

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.

medium

If config.verifier.env is None (which can happen depending on how the Pydantic model is initialized or configured), calling .update() on it will raise an AttributeError. Ensure it is initialized to an empty dictionary before updating.

Suggested change
if args.get("verifier_env"):
env_list = args["verifier_env"]
if isinstance(env_list, list):
config.verifier.env.update({k: v for k, v in (e.split("=", 1) for e in env_list if "=" in e)})
if args.get("verifier_env"):
env_list = args["verifier_env"]
if isinstance(env_list, list):
if config.verifier.env is None:
config.verifier.env = {}
config.verifier.env.update({k: v for k, v in (e.split("=", 1) for e in env_list if "=" in e)})

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

[review] 如果 config.verifier.env 为 None(这取决于 Pydantic 模型的初始化或配置方式),则对其调用 .update() 会引发 AttributeError。请确保在更新之前将其初始化为空字典。

@Keithwwa
Keithwwa merged commit 0ed3f05 into AISBench:master Jun 3, 2026
6 of 7 checks passed
if has_total_count:
row.insert(4, len(sg['subsets']))
row.extend([parsed_results[m].get(sg['name'], {}).get(sg.get('metric', 'naive_average'), '-') for m in self.model_abbrs])
table.append(row)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

【review】mmengine.utils does not contain a TimeStub class or attribute. Attempting to call mmengine.utils.TimeStub.now() will raise an AttributeError and crash the summarizer. Use the standard library datetime module instead.

row = [sg['name'], sg.get('version', '-'), sg.get('metric', 'naive_average'), dataset_eval_mode.get(sg['name'], 'gen')]
if has_total_count:
row.insert(4, len(sg['subsets']))
row.extend([parsed_results[m].get(sg['name'], {}).get(sg.get('metric', 'naive_average'), '-') for m in self.model_abbrs])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

【review】The current implementation of table row construction loops over self.model_abbrs and appends a single model's score to a new row, then appends that row to the table. However, the table header contains columns for all models. This results in malformed rows where the columns do not align with the header (e.g., a row for the second model will have its score displayed under the first model's column, and the row length will not match the header length). Additionally, the summary groups loop will add duplicate rows for each model that has results. We should construct a single row per metric/summary group and populate the scores for all models in that row.

f.write(tabulate.tabulate(table[1:], headers=table[0], tablefmt='grid'))

print(f'write csv to {summary_csv}')
with open(summary_csv, 'w', encoding='utf-8') as out:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

【review】tabulate does not support csv as a table format. Attempting to use tablefmt='csv' will raise a ValueError: unknown table format: csv and crash the summarizer. Write the CSV file manually or use a standard CSV writer.

config.verifier.disable = True
if args.get("verifier_env"):
env_list = args["verifier_env"]
if isinstance(env_list, list):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

【review】If config.verifier.env is None (which can happen depending on how the Pydantic model is initialized or configured), calling .update() on it will raise an AttributeError. Ensure it is initialized to an empty dictionary before updating.

stop_event.set()
raise KeyboardInterrupt

signal.signal(signal.SIGTERM, _handle_sigterm)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

【reivew】In Python, signal.signal can only be called from the main thread. If this task is executed in a non-main thread (e.g., as part of a multi-threaded pipeline or background worker), calling signal.signal will raise a ValueError and crash the task. Wrap the call in a try-except ValueError block to make it safe.

This branch was previously deployed

1 inactive deployment
smoke-test-approval — 2a3f3c8b Deployed Jun 3, 2026 by SJTUyh via run_smoke_test_cases #320
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants