Skip to content

Add utility to validate COGs' compatibility with HyBIG#21

Open
srizvi-NASA wants to merge 4 commits intopodaac:developfrom
srizvi-NASA:add-cog-validation-hybig
Open

Add utility to validate COGs' compatibility with HyBIG#21
srizvi-NASA wants to merge 4 commits intopodaac:developfrom
srizvi-NASA:add-cog-validation-hybig

Conversation

@srizvi-NASA
Copy link

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.

Copy link
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 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:
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
args = parser.parse_args()

# Call the validation function
validate_cog(args.file)
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants