From 06f14e9266232717f96f9cdc8d1e9bb4bc711961 Mon Sep 17 00:00:00 2001 From: Phillip Kelley-Dotson Date: Thu, 14 Jul 2022 14:33:50 -0700 Subject: [PATCH 1/5] first fix --- superset/charts/api.py | 1 + superset/charts/commands/create.py | 1 + superset/datasource/dao.py | 6 ++++++ superset/views/core.py | 2 +- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/superset/charts/api.py b/superset/charts/api.py index e7e511d4fdbd1..0bd5ac822ee79 100644 --- a/superset/charts/api.py +++ b/superset/charts/api.py @@ -288,6 +288,7 @@ def post(self) -> Response: new_model = CreateChartCommand(item).run() return self.response(201, id=new_model.id, result=item) except ChartInvalidError as ex: + print('chart create error') return self.response_422(message=ex.normalized_messages()) except ChartCreateFailedError as ex: logger.error( diff --git a/superset/charts/commands/create.py b/superset/charts/commands/create.py index 8238340794478..c0ccb82fef4eb 100644 --- a/superset/charts/commands/create.py +++ b/superset/charts/commands/create.py @@ -63,6 +63,7 @@ def validate(self) -> None: datasource = get_datasource_by_id(datasource_id, datasource_type) self._properties["datasource_name"] = datasource.name except ValidationError as ex: + print('**** i hit in validationerror create chart command ***') exceptions.append(ex) # Validate/Populate dashboards diff --git a/superset/datasource/dao.py b/superset/datasource/dao.py index c475919abf006..821922ca0de66 100644 --- a/superset/datasource/dao.py +++ b/superset/datasource/dao.py @@ -15,10 +15,12 @@ # specific language governing permissions and limitations # under the License. +import logging from typing import Dict, Type, Union from sqlalchemy.orm import Session + from superset.connectors.sqla.models import SqlaTable from superset.dao.base import BaseDAO from superset.dao.exceptions import DatasourceNotFound, DatasourceTypeNotSupportedError @@ -27,6 +29,9 @@ from superset.tables.models import Table from superset.utils.core import DatasourceType + +logger = logging.getLogger(__name__) + Datasource = Union[Dataset, SqlaTable, Table, Query, SavedQuery] @@ -57,6 +62,7 @@ def get_datasource( ) if not datasource: + logger.warning(f"Datasource not found datasource_type = {datasource_type} datasource_id = {datasource_id}") raise DatasourceNotFound() return datasource diff --git a/superset/views/core.py b/superset/views/core.py index 2985350110aa9..aa8f00665017b 100755 --- a/superset/views/core.py +++ b/superset/views/core.py @@ -815,7 +815,7 @@ def explore( try: datasource = DatasourceDAO.get_datasource( db.session, - DatasourceType(cast(str, datasource_type)), + DatasourceType("table"), datasource_id, ) except DatasetNotFoundError: From 3b329de7abf2b845da1e0c1acd4046f706379b74 Mon Sep 17 00:00:00 2001 From: Phillip Kelley-Dotson Date: Fri, 15 Jul 2022 08:24:26 -0700 Subject: [PATCH 2/5] remove prints --- superset/charts/api.py | 1 - superset/charts/commands/create.py | 1 - 2 files changed, 2 deletions(-) diff --git a/superset/charts/api.py b/superset/charts/api.py index 0bd5ac822ee79..e7e511d4fdbd1 100644 --- a/superset/charts/api.py +++ b/superset/charts/api.py @@ -288,7 +288,6 @@ def post(self) -> Response: new_model = CreateChartCommand(item).run() return self.response(201, id=new_model.id, result=item) except ChartInvalidError as ex: - print('chart create error') return self.response_422(message=ex.normalized_messages()) except ChartCreateFailedError as ex: logger.error( diff --git a/superset/charts/commands/create.py b/superset/charts/commands/create.py index c0ccb82fef4eb..8238340794478 100644 --- a/superset/charts/commands/create.py +++ b/superset/charts/commands/create.py @@ -63,7 +63,6 @@ def validate(self) -> None: datasource = get_datasource_by_id(datasource_id, datasource_type) self._properties["datasource_name"] = datasource.name except ValidationError as ex: - print('**** i hit in validationerror create chart command ***') exceptions.append(ex) # Validate/Populate dashboards From 76f18d14a3d479a811e201f48596a6b52c0f43b4 Mon Sep 17 00:00:00 2001 From: Phillip Kelley-Dotson Date: Mon, 18 Jul 2022 11:12:48 -0700 Subject: [PATCH 3/5] run pc --- superset/datasource/dao.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/superset/datasource/dao.py b/superset/datasource/dao.py index 821922ca0de66..ee501c4bb5664 100644 --- a/superset/datasource/dao.py +++ b/superset/datasource/dao.py @@ -20,7 +20,6 @@ from sqlalchemy.orm import Session - from superset.connectors.sqla.models import SqlaTable from superset.dao.base import BaseDAO from superset.dao.exceptions import DatasourceNotFound, DatasourceTypeNotSupportedError @@ -29,7 +28,6 @@ from superset.tables.models import Table from superset.utils.core import DatasourceType - logger = logging.getLogger(__name__) Datasource = Union[Dataset, SqlaTable, Table, Query, SavedQuery] @@ -62,7 +60,9 @@ def get_datasource( ) if not datasource: - logger.warning(f"Datasource not found datasource_type = {datasource_type} datasource_id = {datasource_id}") + logger.warning( + f"Datasource not found datasource_type = {datasource_type} datasource_id = {datasource_id}" + ) raise DatasourceNotFound() return datasource From c5f6f5cfdd648a207444350526d2cb91210b567b Mon Sep 17 00:00:00 2001 From: Phillip Kelley-Dotson Date: Tue, 19 Jul 2022 11:21:51 -0700 Subject: [PATCH 4/5] fix linter --- superset/datasource/dao.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/superset/datasource/dao.py b/superset/datasource/dao.py index ee501c4bb5664..60aa4348f9958 100644 --- a/superset/datasource/dao.py +++ b/superset/datasource/dao.py @@ -61,7 +61,8 @@ def get_datasource( if not datasource: logger.warning( - f"Datasource not found datasource_type = {datasource_type} datasource_id = {datasource_id}" + "Datasource not found datasource_type: %s, datasource_id: %s", + datasource_type, datasource_id ) raise DatasourceNotFound() From e9396973cba180706ff011beb9a0e6bc1d45a8b8 Mon Sep 17 00:00:00 2001 From: Phillip Kelley-Dotson Date: Tue, 19 Jul 2022 13:18:09 -0700 Subject: [PATCH 5/5] commit --- superset/datasource/dao.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/superset/datasource/dao.py b/superset/datasource/dao.py index 60aa4348f9958..c8df4c8d8d968 100644 --- a/superset/datasource/dao.py +++ b/superset/datasource/dao.py @@ -62,7 +62,8 @@ def get_datasource( if not datasource: logger.warning( "Datasource not found datasource_type: %s, datasource_id: %s", - datasource_type, datasource_id + datasource_type, + datasource_id, ) raise DatasourceNotFound()