-
Notifications
You must be signed in to change notification settings - Fork 29
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 SQLite Backend #148
Merged
Merged
add SQLite Backend #148
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
27caca4
add SQLite Backend
vincentsarago 780a1f6
Update cogeo_mosaic/backends/sqlite.py
vincentsarago e16031f
update from comment
vincentsarago 2348b54
add metadata table and optimize bulk update
vincentsarago 6e5af41
fix
vincentsarago dba6c88
add warning when we update mosaic.name
vincentsarago f2a9234
add tests
vincentsarago 586f253
use MosaicJSON instead of self
vincentsarago 77a918e
update docs
vincentsarago 4224df8
add " around mosaic name to make sure it is valid
vincentsarago aa5baef
add list_mosaics_in_db classmethod and fix edge cases
vincentsarago 6430abd
format
vincentsarago 64d1e1c
Update docs/advanced/backends.md
vincentsarago 50038af
use pathlib
vincentsarago 5847c32
Merge branch 'SQLiteBackend' of https://github.com/developmentseed/co…
vincentsarago File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,6 @@ | |
import attr | ||
import click | ||
import mercantile | ||
from botocore.exceptions import ClientError | ||
from cachetools import TTLCache, cached | ||
from cachetools.keys import hashkey | ||
|
||
|
@@ -33,9 +32,11 @@ | |
try: | ||
import boto3 | ||
from boto3.dynamodb.conditions import Key | ||
from botocore.exceptions import ClientError | ||
except ImportError: # pragma: nocover | ||
boto3 = None # type: ignore | ||
Key = None # type: ignore | ||
ClientError = None # type: ignore | ||
|
||
|
||
@attr.s | ||
|
@@ -151,7 +152,7 @@ def update( | |
"""Update existing MosaicJSON on backend.""" | ||
logger.debug(f"Updating {self.mosaic_name}...") | ||
|
||
new_mosaic = self.mosaic_def.from_features( | ||
new_mosaic = MosaicJSON.from_features( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think using |
||
features, | ||
self.mosaic_def.minzoom, | ||
self.mosaic_def.maxzoom, | ||
|
@@ -284,7 +285,7 @@ def _read(self) -> MosaicJSON: # type: ignore | |
|
||
@cached( | ||
TTLCache(maxsize=cache_config.maxsize, ttl=cache_config.ttl), | ||
key=lambda self, x, y, z: hashkey(self.path, x, y, z), | ||
key=lambda self, x, y, z: hashkey(self.path, x, y, z, self.mosaicid), | ||
) | ||
def get_assets(self, x: int, y: int, z: int) -> List[str]: | ||
"""Find assets.""" | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated to the SQLite backend, but while writing the tests I realized that we were caching this even when the mosaic changed... to fix it we can use the mosaicid (built from the metadata, e.g mosaic version) to make sure we call the function when the mosaic has been updated.