fix: add __init__.py to key_value (#17730)

* Add __init__.py

* Lisence

* Linter

Co-authored-by: Bogdan Kyryliuk <bogdankyryliuk@dropbox.com>
This commit is contained in:
Bogdan 2021-12-15 10:28:32 -08:00 committed by GitHub
parent 6d97e89ad1
commit ec24256407
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 5 deletions

View File

@ -24,13 +24,13 @@ from superset.key_value.utils import cache_key
class GetFilterStateCommand(GetKeyValueCommand):
def get(self, resource_id: int, key: str, refreshTimeout: bool) -> Optional[str]:
def get(self, resource_id: int, key: str, refresh_timeout: bool) -> Optional[str]:
dashboard = DashboardDAO.get_by_id_or_slug(str(resource_id))
if dashboard:
entry: Entry = cache_manager.filter_state_cache.get(
cache_key(resource_id, key)
)
if refreshTimeout:
if refresh_timeout:
cache_manager.filter_state_cache.set(key, entry)
return entry["value"]
return None

View File

@ -0,0 +1,16 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

View File

@ -38,8 +38,8 @@ class GetKeyValueCommand(BaseCommand, ABC):
def run(self) -> Model:
try:
config = app.config["FILTER_STATE_CACHE_CONFIG"]
refreshTimeout = config.get("REFRESH_TIMEOUT_ON_RETRIEVAL")
return self.get(self._resource_id, self._key, refreshTimeout)
refresh_timeout = config.get("REFRESH_TIMEOUT_ON_RETRIEVAL")
return self.get(self._resource_id, self._key, refresh_timeout)
except SQLAlchemyError as ex:
logger.exception("Error running get command")
raise KeyValueGetFailedError() from ex
@ -48,5 +48,5 @@ class GetKeyValueCommand(BaseCommand, ABC):
pass
@abstractmethod
def get(self, resource_id: int, key: str, refreshTimeout: bool) -> Optional[str]:
def get(self, resource_id: int, key: str, refresh_timeout: bool) -> Optional[str]:
...