Skip to content

feat(sanity): check sample data file only if it is valid#269

Merged
ktro2828 merged 1 commit into
mainfrom
feat/sanity/check-if-valid
Apr 9, 2026
Merged

feat(sanity): check sample data file only if it is valid#269
ktro2828 merged 1 commit into
mainfrom
feat/sanity/check-if-valid

Conversation

@ktro2828
Copy link
Copy Markdown
Collaborator

@ktro2828 ktro2828 commented Apr 6, 2026

What

This pull request updates the file existence checks in two sanity reference modules to ensure that only records marked as valid are considered. This prevents unnecessary file-not-found errors for records that are not valid.

Sanity check improvements:

  • Updated t4_devkit/sanity/reference/ref201.py so that the file existence check only applies to records where is_valid is True.
  • Updated t4_devkit/sanity/reference/ref202.py to include the is_valid check before verifying the presence of info_filename and its existence.

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
@github-actions github-actions Bot added the new-feature New feature or request label Apr 6, 2026
@ktro2828 ktro2828 requested a review from Copilot April 6, 2026 03:57
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 6, 2026

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
4217 3491 83% 50% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
t4_devkit/sanity/reference/ref201.py 100% 🟢
t4_devkit/sanity/reference/ref202.py 100% 🟢
TOTAL 100% 🟢

updated for commit: d34bf77 by action🐍

Copy link
Copy Markdown
Contributor

Copilot AI left a 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 PR updates sanity reference checks for SampleData file paths so that file existence is only validated for records that are marked is_valid=True, reducing false “file not found” failures for invalid/ignored records.

Changes:

  • REF201: gate SampleData.filename existence checks behind record["is_valid"].
  • REF202: gate SampleData.info_filename presence/existence checks behind record["is_valid"].

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
t4_devkit/sanity/reference/ref201.py Skip file existence checks for invalid SampleData records.
t4_devkit/sanity/reference/ref202.py Skip info_filename checks for invalid SampleData records.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 35 to +37
Reason(f"File not found: {record['filename']}")
for record in records
if not data_root.joinpath(record["filename"]).exists()
if record.get("is_valid", True) and not data_root.joinpath(record["filename"]).exists()
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

This comprehension can raise a KeyError if a SampleData record is missing the required "filename" key (e.g., malformed JSON): the filter only checks is_valid, but the element expression and exists() path both index record["filename"]. Since checkers are run without exception handling, this can crash the entire sanity run. Consider using record.get("filename") (or similar) and either skip missing filenames or emit a dedicated Reason for missing/empty filename before calling joinpath().

Copilot uses AI. Check for mistakes.
Reason(f"File not found: {record['filename']}")
for record in records
if not data_root.joinpath(record["filename"]).exists()
if record.get("is_valid", True) and not data_root.joinpath(record["filename"]).exists()
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

The new is_valid guard changes REF201 behavior (invalid records should no longer trigger missing-file errors), but there’s no test asserting that an is_valid=False record with a missing/invalid filename is ignored. Adding a focused unit test would prevent regressions and also ensure the checker doesn’t error on intentionally-invalid records.

Copilot uses AI. Check for mistakes.
Reason(f"File not found: {record['filename']}")
for record in records
if not data_root.joinpath(record["filename"]).exists()
if record.get("is_valid", True) and not data_root.joinpath(record["filename"]).exists()
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

For readability/consistency with REF202, consider formatting this condition across multiple lines (or extracting is_valid/filename to locals). The current single-line comprehension is harder to scan and maintain as more guards get added.

Copilot uses AI. Check for mistakes.
Comment on lines +37 to 39
if record.get("is_valid", True)
and record.get("info_filename") is not None
and not data_root.joinpath(record["info_filename"]).exists()
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

The new is_valid guard changes REF202 behavior (invalid records should be ignored), but there’s no test asserting that an is_valid=False record with a missing/nonexistent info_filename does not produce a failure. Adding a unit test for this case would prevent future regressions.

Copilot uses AI. Check for mistakes.
@ktro2828 ktro2828 merged commit a985386 into main Apr 9, 2026
8 of 9 checks passed
@ktro2828 ktro2828 deleted the feat/sanity/check-if-valid branch April 9, 2026 05:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants