Add utility to validate COGs' compatibility with HyBIG#21
Add utility to validate COGs' compatibility with HyBIG#21srizvi-NASA wants to merge 4 commits intopodaac:developfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a validation utility to verify Cloud-Optimized GeoTIFF (COG) files meet HyBIG service requirements. The utility checks that COG files have a defined Coordinate Reference System (CRS) and contain an expected number of bands (1, 3, or 4).
- Implements COG validation logic with CRS and band count checks
- Provides command-line interface for validating individual COG files
- Returns boolean validation results with descriptive error messages
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| print(f"COG file {file_path} is valid.") | ||
| return True | ||
| | ||
| except Exception as e: |
There was a problem hiding this comment.
Catching a broad Exception masks specific errors and makes debugging difficult. Consider catching specific exceptions like rasterio.RasterioIOError or FileNotFoundError to handle different failure scenarios appropriately.
| args = parser.parse_args() | ||
| | ||
| # Call the validation function | ||
| validate_cog(args.file) |
There was a problem hiding this comment.
The return value from validate_cog() is not used to set the script's exit code. This means the script will always exit with code 0, even when validation fails. Consider using sys.exit(0 if validate_cog(args.file) else 1) to properly signal validation success or failure to calling processes.
This is for Implement Validation Checks for COGs (Issue #17). I have added it as a utility, but in future, this can be used as a separate job/service/or simple a function.