Repository navigation
r.semantic.label: exit with error when print target is missing - #7496
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds regression coverage and updates r.semantic.label to return a non-zero exit code when operation=print is run on a missing raster map, aligning it with add/remove behavior.
Changes:
- Add tests covering
operation=printbehavior for missing vs existing maps. - Make
print_map_semantic_label()return a status code and propagate failures frommain().
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| scripts/r.semantic.label/tests/r_semantic_label_test.py | Adds regression tests to ensure missing-map print fails and existing-map print succeeds. |
| scripts/r.semantic.label/r.semantic.label.py | Returns explicit status from print_map_semantic_label() and propagates failures to module exit code. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
operation=print printed an error but exited successfully when the raster map was not found, because print_map_semantic_label returned None on OpenError and main() ignored it. The add/remove path returns 1 for the same condition and main() propagates it. Make print return a status (1 on a missing map, 0 otherwise) and have main() honor it, so all operations exit consistently. Add a regression test.
8b92a26 to
23ac67e
Compare
|
Heads up for reviewers: the failing pytest check is from the r.param.scale reference test, not this PR, which only touches r.semantic.label. That test was added recently (#7534/#7584) and is known to be flaky across platforms. Even main passes and fails intermittently on the same workflow due to the OpenMP issue tracked in #1168. The py3.10 job also hung for ~80 minutes, which matches the same problem.
|
|
Thanks Anna, done. The test now catches |
…#7496) operation=print printed an error but exited successfully when the raster map was not found, because print_map_semantic_label returned None on OpenError and main() ignored it. The add/remove path returns 1 for the same condition and main() propagates it. Make print return a status (1 on a missing map, 0 otherwise) and have main() honor it, so all operations exit consistently.
Description
operation=printprinted an error but exited successfully when the rastermap was not found, because
print_map_semantic_labelreturnedNoneonOpenErrorandmain()ignored its return value. The add/remove path returns1for the same missing-map condition andmain()propagates it, so theexit codes were inconsistent across operations:
This makes
print_map_semantic_labelreturn a status (1on a missing map,0otherwise) and hasmain()honor it, so all operations exit consistently.Motivation and context
A tool that reports
ERROR: Map <…> not foundshould not exit 0 — scripts andpipelines rely on the exit code. The add/remove path already does the right
thing; this aligns
printwith it.How has this been tested?
Reproduced locally before and after the change. Added a regression test
(
scripts/r.semantic.label/tests/r_semantic_label_test.py):printon amissing map now raises (fails on the previous code, passes on the fix), and
printon an existing map without a label still succeeds.ruff formatandruff checkare clean.Types of changes