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

Configurable up-zooming of tiles from Redshift #311

Merged
merged 2 commits into from
Nov 28, 2017

Conversation

zerebubuth
Copy link
Member

This changes the TOI gardener/pruner to parse the tile size and use the configured metatile size to up-zoom access logs to the metatile they're part of.

Matt Amos added 2 commits November 28, 2017 13:05
This changes the TOI gardener/pruner to parse the tile size and use the configured metatile size to up-zoom access logs to the metatile they're part of.
assert tile_size_as_zoom <= cfg.metatile_zoom
tile_zoom_offset = tile_size_as_zoom - cfg.metatile_zoom

except AssertionError:
Copy link
Member

Choose a reason for hiding this comment

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

Would this be better as an if block rather than a try/assert/except?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, if that were the only assertion. Unfortunately, there's also one in metatile_zoom_from_size, called by metatile_zoom_from_str, which asserts that the metatile size is a power of two. I don't think it's possible to get a (200 OK) entry in the database like that, but I think we wouldn't want this process to stop in that case.

I could rewrite both functions to return None on error, and check for that. Do you think that would be better than the try/except?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, didn't see the other assertion. 👍

Copy link
Member

Choose a reason for hiding this comment

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

Catching an assertion error seems odd to me as well, and perhaps it would be better to return None instead and check for that at call sites.

By the way, it doesn't look like we're filtering on successful responses here, or I just missed it. Should we be?

Copy link
Member

Choose a reason for hiding this comment

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

By successful responses, I just meant that we'd only consider 200 and 304 responses, because we could get garbage with 404s. But, the query looks like it'll guarantee that we always get valid coordinates, so on second thought maybe it's better to just leave the way it is. After all, we are interested in the requested coordinates here, regardless of what the response looked like, eg 5xx responses should be considered.

Never mind! :)

assert tile_size_as_zoom <= cfg.metatile_zoom
tile_zoom_offset = tile_size_as_zoom - cfg.metatile_zoom

except AssertionError:
Copy link
Member

Choose a reason for hiding this comment

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

Catching an assertion error seems odd to me as well, and perhaps it would be better to return None instead and check for that at call sites.

By the way, it doesn't look like we're filtering on successful responses here, or I just missed it. Should we be?

@zerebubuth zerebubuth merged commit 0c3473c into master Nov 28, 2017
@zerebubuth zerebubuth deleted the zerebubuth/toi-gardener-1024px-tiles branch November 28, 2017 16:06
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.

3 participants