- 
                Notifications
    You must be signed in to change notification settings 
- Fork 19
Refactor and update file checks logic #373
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
          
     Merged
      
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            18 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      2035ffb
              
                Refactor and update file checks logic
              
              
                fdrose 6c50c1f
              
                Style
              
              
                fdrose 2c14af0
              
                Style
              
              
                fdrose 1a261d0
              
                Fix message dtype
              
              
                fdrose 4a7797e
              
                Fix check return type
              
              
                fdrose dfea707
              
                fix tests
              
              
                fdrose f11307e
              
                fix tests
              
              
                fdrose 775167b
              
                fix tests
              
              
                fdrose 88c54fc
              
                style
              
              
                fdrose 0aae8f2
              
                add tests
              
              
                fdrose 4fd70eb
              
                style
              
              
                fdrose b08bdda
              
                Merge branch 'main' into mabraham/eng-29561
              
              
                fdrose bbc32bc
              
                fix test
              
              
                fdrose 2a1efd1
              
                fix return type
              
              
                fdrose c79aca1
              
                fix return type
              
              
                fdrose 93e580a
              
                bump version
              
              
                fdrose 92e4748
              
                bump version
              
              
                fdrose 92be6d7
              
                Merge branch 'main' into mabraham/eng-29561
              
              
                fdrose File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
          Some comments aren't visible on the classic Files Changed page.
        
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -182,7 +182,12 @@ def test_check_jsonl_inconsistent_dataset_format(tmp_path: Path): | |
| # Create a JSONL file with inconsistent dataset formats | ||
| file = tmp_path / "inconsistent_format.jsonl" | ||
| content = [ | ||
| {"messages": [{"role": "user", "content": "Hi"}]}, | ||
| { | ||
| "messages": [ | ||
| {"role": "user", "content": "Hi"}, | ||
| {"role": "assistant", "content": "Hi! How can I help you?"}, | ||
| ] | ||
| }, | ||
| {"text": "How are you?"}, # Missing 'messages' | ||
| ] | ||
| with file.open("w") as f: | ||
|  | @@ -207,7 +212,7 @@ def test_check_jsonl_invalid_role(tmp_path: Path): | |
| report = check_file(file) | ||
|  | ||
| assert not report["is_check_passed"] | ||
| assert "Found invalid role `invalid_role`" in report["message"] | ||
| assert "Invalid role `invalid_role` in conversation" in report["message"] | ||
|         
                  cursor[bot] marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
|  | ||
|  | ||
| def test_check_jsonl_non_alternating_roles(tmp_path: Path): | ||
|  | @@ -230,6 +235,22 @@ def test_check_jsonl_non_alternating_roles(tmp_path: Path): | |
| assert "Invalid role turns" in report["message"] | ||
|  | ||
|  | ||
| def test_check_jsonl_assistant_role_exists(tmp_path: Path): | ||
| # Create a JSONL file with no assistant role | ||
| file = tmp_path / "assistant_role_exists.jsonl" | ||
| content = [{"messages": [{"role": "user", "content": "Hi"}]}] | ||
| with file.open("w") as f: | ||
| f.write("\n".join(json.dumps(item) for item in content)) | ||
|  | ||
| report = check_file(file) | ||
|  | ||
| assert not report["is_check_passed"] | ||
| assert ( | ||
| "At least one message with the assistant role must be present" | ||
| in report["message"] | ||
| ) | ||
|  | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Duplicate Test Overwrites Original CaseThe  | ||
|  | ||
| def test_check_jsonl_invalid_value_type(tmp_path: Path): | ||
| # Create a JSONL file with an invalid value type | ||
| file = tmp_path / "invalid_value_type.jsonl" | ||
|  | @@ -257,7 +278,7 @@ def test_check_jsonl_missing_field_in_conversation(tmp_path: Path): | |
|  | ||
| report = check_file(file) | ||
| assert not report["is_check_passed"] | ||
| assert "Field `content` is missing for a turn" in report["message"] | ||
| assert "Missing required column `content`" in report["message"] | ||
|  | ||
|  | ||
| def test_check_jsonl_wrong_turn_type(tmp_path: Path): | ||
|  | @@ -277,7 +298,7 @@ def test_check_jsonl_wrong_turn_type(tmp_path: Path): | |
| report = check_file(file) | ||
| assert not report["is_check_passed"] | ||
| assert ( | ||
| "Invalid format on line 1 of the input file. Expected a dictionary" | ||
| "Invalid format on line 1 of the input file. The `messages` column must be a list of dicts." | ||
| in report["message"] | ||
| ) | ||
|  | ||
|  | @@ -301,9 +322,7 @@ def test_check_jsonl_empty_messages(tmp_path: Path): | |
|  | ||
| report = check_file(file) | ||
| assert not report["is_check_passed"] | ||
| assert ( | ||
| "Expected a non-empty list of messages. Found empty list" in report["message"] | ||
| ) | ||
| assert "The `messages` column must not be empty" in report["message"] | ||
|  | ||
|  | ||
| def test_check_jsonl_valid_weights_all_messages(tmp_path: Path): | ||
|  | ||
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
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.
Bug: Validation Checks Incomplete for Output Fields
The
validate_preference_openaifunction no longer applies comprehensivevalidate_messageschecks topreferred_outputandnon_preferred_output. These fields now only receive basic structural validation, which could allow malformed messages.