Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validateCOG method to GDALFileTileSource #835

Merged
merged 9 commits into from
Apr 27, 2022
Merged

Add validateCOG method to GDALFileTileSource #835

merged 9 commits into from
Apr 27, 2022

Conversation

banesullivan
Copy link
Contributor

This adds a validate_cog method to GDALFileTileSource to use the osgeo_utils script that will verify a COG.

I'm wondering if we should add another validate_* method to the TiledTiffDirectory that uses tifftools to check the IFDs and tiling of an image

@manthey
Copy link
Member

manthey commented Apr 26, 2022

We should figure out how to harmonize this with the "inefficient warning" here https://github.com/girder/large_image/blob/master/sources/tiff/large_image_source_tiff/__init__.py#L324-L339

@manthey
Copy link
Member

manthey commented Apr 26, 2022

If a file is small enough, even if it isn't a COG, we probably shouldn't consider it a problem (e.g., if a file is only a few kilobytes, the fact it isn't tiled or optimized is probably irrelevant). Since there are formats that are efficient that aren't tiff, so we probably can only intelligently detect that a file is inefficient in a small set of cases.

@banesullivan
Copy link
Contributor Author

banesullivan commented Apr 26, 2022

If a file is small enough, even if it isn't a COG, we probably shouldn't consider it a problem ...

I'm not sure if I'd like this new validate_cog method to handle that, I think this method should solely inform users on whether it is a valid COG or not regardless of size.

IMO, any downstream library that is calling this function should handle the cursory check of: is this under my file size threshold? no? then check if valid COG.

We should figure out how to harmonize this with the "inefficient warning"

Hm. should I add _checkForInefficientDirectories() as an abstract method on FileTileSource and let the GDAL source override it as:

    def _checkForInefficientDirectories(self, warn=True):
        try:
            return self.validate_cog(warn=warn)
        except TileSourcePyramidFormatError:
            pass
        self._inefficientWarning = True

@banesullivan banesullivan changed the title Add validate_cog method to GDALFileTileSource Add validateCOG method to GDALFileTileSource Apr 26, 2022
@manthey
Copy link
Member

manthey commented Apr 27, 2022

Hm. should I add _checkForInefficientDirectories() as an abstract method on FileTileSource and let the GDAL source override it as:

    def _checkForInefficientDirectories(self, warn=True):
        try:
            return self.validate_cog(warn=warn)
        except TileSourcePyramidFormatError:
            pass
        self._inefficientWarning = True

Let's defer this to a later conversation or PR. There is another project where we may try to determine this for more different sources and we can take it back up then.

@banesullivan
Copy link
Contributor Author

Let's defer this to a later conversation or PR. There is another project where we may try to determine this for more different sources and we can take it back up then.

Sounds good. I think it'd be nice to have a generalized efficiency check on the base class which the GDAL and TIFF sources can override with their respective checks.

Considering this, I renamed the exception type from [TileSourcePyramidFormatError to TileSourceInefficientError

@manthey
Copy link
Member

manthey commented Apr 27, 2022

I pushed a change to the test that checks which sources can read which files so that the new test files don't cause tests to fail.

@manthey manthey merged commit b999c5c into master Apr 27, 2022
@manthey manthey deleted the validate-cog branch April 27, 2022 15:52
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.

2 participants