-
Notifications
You must be signed in to change notification settings - Fork 141
Fix/transformers eval #1191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/transformers eval #1191
Conversation
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.
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.
There was a problem hiding this 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():
closes #1118