Skip to content

Fix TSV formatting so GitHub's file preview works (#233) - #325

Merged
dweindl merged 1 commit into
Benchmarking-Initiative:masterfrom
dweindl:worktree-233
Sep 25, 2026
Merged

dweindl merged 1 commit into
Benchmarking-Initiative:masterfrom
dweindl:worktree-233

Conversation

@dweindl

@dweindl dweindl commented Sep 25, 2026

Copy link
Copy Markdown
Member

GitHub's TSV preview breaks when a row has a different number of columns than the header, and several files had mixed line endings. Closes #233.

Root cause: the top-level files: src/python restriction in .pre-commit-config.yaml scoped every hook in the file — including trailing-whitespace, mixed-line-ending, and end-of-file-fixer — to src/python/ only, so the actual PEtab data files under Benchmark-Models/ were never checked or normalized.

Changes:

  • Added bmp-check-tsv-format (benchmark_models_petab/check_tsv_format.py), which checks every *.tsv file for consistent field count vs. the header, consistent line endings, no stray leading/trailing whitespace in a field, and exactly one trailing newline. Wired into tests.yml alongside bmp-petablint.
  • Fixed the 19 files it flagged: normalized CRLF/mixed line endings to LF and added missing final newlines (via the broadened pre-commit hooks), padded 114 short rows in Bachmann_MSB2011/parameters_Bachmann_MSB2011.tsv (they were missing their two optional prior columns entirely), and trimmed stray whitespace from a handful of field values.
  • Extended .pre-commit-config.yaml's end-of-file-fixer and mixed-line-ending hooks to also cover *.tsv anywhere in the repo, and restored the previous src/python-only scope explicitly on every other hook (check-yaml, check-added-large-files, check-merge-conflict, check-symlinks, check-executables-have-shebangs, detect-private-key, ruff, ruff-format). trailing-whitespace is deliberately not extended to *.tsv, since it strips trailing tabs that PEtab TSVs use to encode a legitimately empty last column — doing so would recreate the very column-mismatch bug this fixes.
  • Added unit tests for check_tsv_file in src/python/test/.

🤖 Generated with Claude Code

…-Initiative#233)

GitHub's TSV file preview breaks when a row has a different number
of columns than the header. Mixed line endings were also present in
several files.

Root cause: the top-level `files: src/python` restriction in
.pre-commit-config.yaml scoped every hook in the file - including
trailing-whitespace, mixed-line-ending, and end-of-file-fixer -
to src/python/ only, so the actual PEtab data files under
Benchmark-Models/ were never checked or normalized.

- Add bmp-check-tsv-format (benchmark_models_petab/check_tsv_format.py),
  which checks every *.tsv file for: consistent field count vs. the
  header, consistent line endings, no stray leading/trailing
  whitespace in a field, and exactly one trailing newline. Wire it
  into tests.yml alongside bmp-petablint.
- Fix the 19 files it flagged: normalize CRLF/mixed line endings to
  LF and add missing final newlines (via the broadened pre-commit
  hooks below), pad short rows in
  Bachmann_MSB2011/parameters_Bachmann_MSB2011.tsv (114 rows were
  missing their two optional prior columns entirely), and trim stray
  whitespace from a handful of field values.
- Extend .pre-commit-config.yaml's end-of-file-fixer and
  mixed-line-ending hooks to also cover *.tsv anywhere in the repo,
  and restore the previous src/python-only scope explicitly on every
  other hook (check-yaml, check-added-large-files, check-merge-conflict,
  check-symlinks, check-executables-have-shebangs, detect-private-key,
  ruff, ruff-format). trailing-whitespace is deliberately NOT extended
  to *.tsv, since it strips trailing tabs that PEtab TSVs use to
  encode a legitimately empty last column - doing so would recreate
  the very column-mismatch bug this fixes.
- Add unit tests for check_tsv_file in src/python/test/.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@dweindl
dweindl marked this pull request as ready for review September 25, 2026 09:00

@dilpath dilpath left a comment

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.

Thanks!

Comment thread .pre-commit-config.yaml
hooks:
- id: check-yaml
description: Check yaml files for parseable syntax
files: ^src/python/

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.

Unfortunate that it doesn't look easy to have separate pre-commit configs for the Python code and the PEtab problems.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I didn't find a more convenient option either, but I think it's quite manageable...

@dweindl
dweindl merged commit 33615a4 into Benchmarking-Initiative:master Sep 25, 2026
3 checks passed
@dweindl
dweindl deleted the worktree-233 branch September 25, 2026 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check/fix tsv files to enable preview

2 participants