Skip to content

Conversation

SAKURA-CAT
Copy link
Member

@SAKURA-CAT SAKURA-CAT commented Jul 18, 2025

  1. 修复多线程下由 tqdm 造成的奇怪句柄冲突问题,处理方式是 try-catch 后直接 pass,后续等 [REQUEST] 增加Debug日志文件 #1132 上线后加入此文件中
  2. 修复 transformers 框架下的评测日志乱码问题
  3. 改进 add transformers test script #1184 的测试脚本
  4. 修复local环境下错误的 watch 目录提示

closes #1118

Added a TypeError exception handler in the backup function to address issues occurring when integrating with transformers, specifically when using Ctrl+C and tqdm does not exit immediately.
Refactored the logic for removing control sequences from log lines by introducing the remove_control_sequences function, which handles both carriage returns and ANSI escape sequences more robustly. Updated clean_control_chars to use this new function and expanded unit tests to cover various edge cases for control sequence removal.
Introduces argparse to allow customization of sample count and sequence length from the command line. Updates output directory handling, adds evaluation strategy and steps, and improves overall script flexibility for Qwen2 model fake training.
@SAKURA-CAT SAKURA-CAT self-assigned this Jul 18, 2025
@SAKURA-CAT SAKURA-CAT added 🐛 bug Something isn't working 💪 enhancement New feature or request labels Jul 18, 2025
Copilot

This comment was marked as outdated.

Updated the ANSI escape sequence regex for more accurate matching and modified the clean_control_chars function to remove empty lines from the result. This improves the cleanliness and readability of processed log output.
Replaces standalone test functions for clean_control_chars with a class-based approach using static methods. Adds more granular and descriptive test cases to improve coverage and clarity.
Updated the utils.print_watch call to use self.run_store.swanlog_dir, ensuring the correct directory is referenced when printing watch information after run completion.
@SAKURA-CAT SAKURA-CAT requested a review from Copilot July 18, 2025 10:00
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 pull request fixes multiple issues related to evaluation and logging in the SwanLab framework, particularly focusing on transformers integration and multi-threading stability.

  • Fixes threading issues with tqdm causing handle conflicts in multi-threaded environments
  • Resolves garbled log output issues in transformers framework evaluation
  • Improves test scripts and fixes incorrect watch directory paths in local environment

Reviewed Changes

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

Show a summary per file
File Description
test/unit/log/test_log.py Rewrites and expands unit tests for control character cleaning functions
test/integration/transformers/transformers_fake_train.py Enhances transformers integration test with configuration options and evaluation strategy
swanlab/log/log.py Improves control character cleaning with new regex pattern and dedicated function
swanlab/data/porter/init.py Adds TypeError exception handling for tqdm threading issues
swanlab/data/callbacker/local.py Fixes incorrect watch directory path from run_dir to swanlog_dir
Comments suppressed due to low confidence (5)

test/unit/log/test_log.py:269

  • The test method name is missing the 'test_' prefix which is required for pytest to recognize it as a test method.
    def removes_escape_sequence_and_returns_content_after():

test/unit/log/test_log.py:274

  • The test method name is missing the 'test_' prefix which is required for pytest to recognize it as a test method.
    def returns_original_line_if_no_control_sequence():

test/unit/log/test_log.py:279

  • The test method name is missing the 'test_' prefix which is required for pytest to recognize it as a test method.
    def handles_multiple_control_sequences_and_returns_content_after_last():

test/unit/log/test_log.py:284

  • The test method name is missing the 'test_' prefix which is required for pytest to recognize it as a test method.
    def handles_empty_string_and_returns_empty():

test/unit/log/test_log.py:289

  • The test method name is missing the 'test_' prefix which is required for pytest to recognize it as a test method.
    def handles_only_control_sequence_and_returns_empty():

@SAKURA-CAT SAKURA-CAT merged commit c278e2b into main Jul 18, 2025
5 checks passed
@SAKURA-CAT SAKURA-CAT deleted the fix/transformers-eval branch July 18, 2025 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working 💪 enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] transformers eval 时进度条显示问题
2 participants