Skip to content

feat: add validate_landmarks() for JSON and CSV landmark file validation#420

Merged
dreamlessx merged 3 commits intodreamlessx:mainfrom
P-r-e-m-i-u-m:feat/validate-landmarks-v2
Mar 22, 2026
Merged

feat: add validate_landmarks() for JSON and CSV landmark file validation#420
dreamlessx merged 3 commits intodreamlessx:mainfrom
P-r-e-m-i-u-m:feat/validate-landmarks-v2

Conversation

@P-r-e-m-i-u-m
Copy link
Contributor

Closes #402

Adds validate_landmarks() utility to landmarkdiff/validation.py to check landmark files before processing.

Changes

landmarkdiff/validation.py

  • Added LandmarkValidationResult dataclass with valid, errors, warnings, landmark_count, dimensions
  • Added validate_landmarks(path) supporting .json and .csv formats
  • Validates: file exists, valid format, expected count (478 MediaPipe / 68 dlib), 2D/3D coordinates, NaN/Inf values, coordinate bounds, confidence scores
  • Added _parse_landmark_json() and _parse_landmark_csv() helpers

Usage

Signed-off-by: 🄂ʏᴇᴅ 🄰ʙᴅᴜʟ 🄰ᴍᴀ🄝 ✧ <amanbaba9404522@gmail.com>
@P-r-e-m-i-u-m
Copy link
Contributor Author

PR #420 is open! CI running, review requested from dreamlessx.
Also comment on the old PR #407 to let dreamlessx know:
"Superseded by #420 which is rebased onto latest main. Please close this one.

@dreamlessx
Copy link
Owner

Thanks @P-r-e-m-i-u-m — this is a much cleaner approach than #407! Good call making a fresh PR.

The validate_landmarks() function looks solid: JSON/CSV parsing, NaN/Inf/OOB checks, confidence filtering, and the LandmarkValidationResult dataclass is a clean API.

CI is failing on lint — quick fix:

ruff check landmarkdiff/validation.py --fix
ruff format landmarkdiff/validation.py
git add -u && git commit -m "style: fix lint" && git push

One style note: the private-prefixed imports (_csv, _json, _dataclass) are unusual — standard practice is to just import normally and let __all__ control the public API. Not blocking, just a thought for consistency.

Fix the lint and this is ready to merge! You can also close #407 since this replaces it.

…ting

Signed-off-by: 🄂ʏᴇᴅ 🄰ʙᴅᴜʟ 🄰ᴍᴀ🄝 ✧ <amanbaba9404522@gmail.com>
@P-r-e-m-i-u-m
Copy link
Contributor Author

"Fixed lint — moved imports to top of file, switched to standard names (csv, json, math, dataclass, field), and fixed formatting. Ready for merge @dreamlessx

@dreamlessx
Copy link
Owner

Almost there! Lint rules pass now but the formatter still wants to reformat the file. Two separate steps:

ruff check landmarkdiff/validation.py    # lint rules (this passes now)
ruff format landmarkdiff/validation.py   # formatting (this is what's failing)
git add -u && git commit -m "style: format validation.py" && git push

One more push and it's green.

Signed-off-by: 🄂ʏᴇᴅ 🄰ʙᴅᴜʟ 🄰ᴍᴀ🄝 ✧ <amanbaba9404522@gmail.com>
@P-r-e-m-i-u-m
Copy link
Contributor Author

"Formatted with ruff format. Should be green now — ready for merge @dreamlessx

@codecov
Copy link

codecov bot commented Mar 22, 2026

Codecov Report

❌ Patch coverage is 14.28571% with 102 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
landmarkdiff/validation.py 14.28% 102 Missing ⚠️

📢 Thoughts on this report? Let us know!

@dreamlessx
Copy link
Owner

All CI checks pass -- the only failure is codecov/patch (coverage threshold), which isn't blocking. Merging now. Nice work @P-r-e-m-i-u-m, thanks for sticking with it through the lint iterations!

@dreamlessx dreamlessx merged commit 930eebf into dreamlessx:main Mar 22, 2026
6 of 7 checks passed
@P-r-e-m-i-u-m
Copy link
Contributor Author

Ready for merge @dreamlessx 👍"

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.

Add data validation for landmark file formats

2 participants