Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/together/utils/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@ def _check_jsonl(file: Path) -> Dict[str, Any]:
error_source="format",
)

# Check that there are not extra columns
for column in json_line:
if (
column
not in JSONL_REQUIRED_COLUMNS_MAP[possible_format]
):
raise InvalidFileFormatError(
message=f"Found extra column {column} in the line {idx + 1}.",
line_number=idx + 1,
error_source="format",
)

if current_format is None:
raise InvalidFileFormatError(
message=(
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/test_files_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,14 @@ def test_check_jsonl_wrong_turn_type(tmp_path: Path):
"Invalid format on line 1 of the input file. Expected a dictionary"
in report["message"]
)


def test_check_jsonl_extra_column(tmp_path: Path):
file = tmp_path / "extra_column.jsonl"
content = [{"text": "Hello, world!", "extra_column": "extra"}]
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 "Found extra column" in report["message"]
Loading