Skip to content

Commit

Permalink
Removes database model
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-s-molina committed Nov 29, 2021
1 parent adc0409 commit b9004e0
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 46 deletions.
5 changes: 0 additions & 5 deletions superset/dashboards/filter_state/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from superset.dashboards.filter_state.commands.update import UpdateFilterStateCommand
from superset.extensions import event_logger
from superset.key_value.api import KeyValueRestApi
from superset.views.base_api import statsd_metrics

logger = logging.getLogger(__name__)

Expand All @@ -51,7 +50,6 @@ def get_delete_command(self) -> Type[DeleteFilterStateCommand]:
@expose("/<int:pk>/filter_state", methods=["POST"])
@protect()
@safe
@statsd_metrics
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.post",
log_to_statsd=False,
Expand Down Expand Up @@ -99,7 +97,6 @@ def post(self, pk: int) -> Response:
@expose("/<int:pk>/filter_state/<string:key>/", methods=["PUT"])
@protect()
@safe
@statsd_metrics
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.put",
log_to_statsd=False,
Expand Down Expand Up @@ -153,7 +150,6 @@ def put(self, pk: int, key: str) -> Response:
@expose("/<int:pk>/filter_state/<string:key>/", methods=["GET"])
@protect()
@safe
@statsd_metrics
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.get",
log_to_statsd=False,
Expand Down Expand Up @@ -200,7 +196,6 @@ def get(self, pk: int, key: str) -> Response:
@expose("/<int:pk>/filter_state/<string:key>/", methods=["DELETE"])
@protect()
@safe
@statsd_metrics
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.delete",
log_to_statsd=False,
Expand Down
10 changes: 2 additions & 8 deletions superset/key_value/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,17 @@
from typing import Any

from flask import g, request, Response
from flask_appbuilder.api import BaseApi
from flask_appbuilder.models.sqla.interface import SQLAInterface

from superset.constants import MODEL_API_RW_METHOD_PERMISSION_MAP, RouteMethod
from superset.exceptions import InvalidPayloadFormatError
from superset.key_value.commands.create import CreateKeyValueCommand
from superset.key_value.commands.delete import DeleteKeyValueCommand
from superset.key_value.commands.get import GetKeyValueCommand
from superset.key_value.commands.update import UpdateKeyValueCommand
from superset.key_value.schemas import KeyValuePostSchema, KeyValuePutSchema
from superset.models.key_value import KeyValueEntry
from superset.views.base_api import BaseSupersetModelRestApi

logger = logging.getLogger(__name__)


class KeyValueRestApi(BaseSupersetModelRestApi, ABC):
datamodel = SQLAInterface(KeyValueEntry)
class KeyValueRestApi(BaseApi, ABC):
add_model_schema = KeyValuePostSchema()
edit_model_schema = KeyValuePutSchema()
method_permission_name = MODEL_API_RW_METHOD_PERMISSION_MAP
Expand Down
2 changes: 1 addition & 1 deletion superset/key_value/commands/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def run(self) -> Model:
self.create(self._resource_id, key, value)
return key
except SQLAlchemyError as ex:
logger.exception(ex.exception)
logger.exception("Error running create command")
raise KeyValueCreateFailedError() from ex
return False

Expand Down
2 changes: 1 addition & 1 deletion superset/key_value/commands/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def run(self) -> Model:
try:
return self.delete(self._resource_id, self._key)
except SQLAlchemyError as ex:
logger.exception(ex.exception)
logger.exception("Error running delete command")
raise KeyValueDeleteFailedError() from ex

def validate(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion superset/key_value/commands/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def run(self) -> Model:
refreshTimeout = config.get("REFRESH_TIMEOUT_ON_RETRIEVAL")
return self.get(self._resource_id, self._key, refreshTimeout)
except SQLAlchemyError as ex:
logger.exception(ex.exception)
logger.exception("Error running get command")
raise KeyValueGetFailedError() from ex

def validate(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion superset/key_value/commands/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def run(self) -> Model:
if value:
return self.update(self._resource_id, self._key, value)
except SQLAlchemyError as ex:
logger.exception(ex.exception)
logger.exception("Error running update command")
raise KeyValueUpdateFailedError() from ex
return False

Expand Down
29 changes: 0 additions & 29 deletions superset/models/key_value.py

This file was deleted.

0 comments on commit b9004e0

Please sign in to comment.