-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring configurations and examples.
- Loading branch information
1 parent
1a47f9b
commit 53f9c5a
Showing
47 changed files
with
1,030 additions
and
1,349 deletions.
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
13 changes: 9 additions & 4 deletions
13
example/recipes/collection/CMIP6.CMIP.MOHC.UKESM1-0-LL.yaml
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 |
---|---|---|
|
@@ -8,29 +8,38 @@ | |
__license__ = "BSD - see LICENSE file in top-level package directory" | ||
__contact__ = "[email protected]" | ||
|
||
from abc import ABC, abstractmethod | ||
from abc import abstractmethod | ||
|
||
from cachetools import Cache | ||
from pydantic import BaseModel, Field | ||
|
||
from stac_generator.core.process_config import SetConfig | ||
|
||
class BaseBulkOutput(ABC): | ||
|
||
class BulkOutputConf(BaseModel): | ||
"""Elasticsearch config model.""" | ||
|
||
cache_max_size: str = Field( | ||
description="Max size of cache.", | ||
) | ||
|
||
|
||
class BulkOutput(SetConfig): | ||
""" | ||
Base class to define an bulk output | ||
""" | ||
|
||
config_class = BulkOutputConf | ||
|
||
def __init__(self, **kwargs): | ||
""" | ||
Set the kwargs to generate instance attributes of the same name and create cache | ||
:param kwargs: | ||
""" | ||
for k, v in kwargs.items(): | ||
setattr(self, k, v) | ||
|
||
if not hasattr(self, "cache_max_size"): | ||
self.cache_max_size = 100 | ||
super().__init__(**kwargs) | ||
|
||
self.data_cache = Cache(maxsize=self.cache_max_size + 1) | ||
self.data_cache = Cache(maxsize=self.conf.cache_max_size + 1) | ||
|
||
def __del__(self): | ||
self.clear_cache() | ||
|
@@ -68,7 +77,7 @@ def run(self, data: dict) -> None: | |
# add to cache | ||
self.data_cache.update(self.data_to_cache(data)) | ||
|
||
if self.data_cache.currsize >= self.cache_max_size: | ||
if self.data_cache.currsize >= self.conf.cache_max_size: | ||
self.clear_cache() | ||
|
||
def clear_cache(self) -> None: | ||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.