You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/11/17 20:26:01 UTC

[GitHub] [superset] Antonio-RiveroMartnez commented on a diff in pull request #22148: feat(ssh_tunnel): Create command & exceptions

Antonio-RiveroMartnez commented on code in PR #22148:
URL: https://github.com/apache/superset/pull/22148#discussion_r1025671129


##########
superset/databases/commands/create.py:
##########
@@ -71,6 +71,10 @@ def run(self) -> Model:
             database = DatabaseDAO.create(self._properties, commit=False)
             database.set_sqlalchemy_uri(database.sqlalchemy_uri)
 
+            # create ssh tunnel

Review Comment:
   Should we remove this comment block?



##########
tests/unit_tests/databases/dao/dao_tests.py:
##########
@@ -50,7 +53,7 @@ def session_with_data(session: Session) -> Iterator[Session]:
     session.rollback()
 
 
-def test_database_get_shh_tunnel(session_with_data: Session) -> None:
+def test_database_get_ssh_tunnel(session_with_data: Session) -> None:

Review Comment:
   Wondering what "changed" here because I see no difference 🤔 👀 



##########
superset/databases/ssh_tunnel/commands/create.py:
##########
@@ -0,0 +1,49 @@
+# 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.
+import logging
+from typing import Any, Dict, List, Optional
+
+from flask_appbuilder.models.sqla import Model
+from marshmallow import ValidationError
+
+from superset.commands.base import BaseCommand
+from superset.dao.exceptions import DAOCreateFailedError
+from superset.databases.commands.exceptions import SSHTunnelCreateFailedError
+from superset.databases.commands.test_connection import TestConnectionDatabaseCommand
+from superset.databases.ssh_tunnel.dao import SSHTunnelDAO
+
+logger = logging.getLogger(__name__)
+
+
+class CreateSSHTunnelCommand(BaseCommand):
+    def __init__(self, database_id: int, data: Dict[str, Any]):
+        self._properties = data.copy()
+        self._properties["database_id"] = database_id

Review Comment:
   Why not pulling it from the `data` dict instead of having `database_id` as a separated arg? I mean, even in the `create_test.py` (dao and command) you have the `database_id` as part of the properties of the tunnel.



##########
superset/databases/commands/exceptions.py:
##########
@@ -176,3 +176,8 @@ class DatabaseOfflineError(SupersetErrorException):
 
 class InvalidParametersError(SupersetErrorsException):
     status = 422
+
+
+class SSHTunnelCreateFailedError(CommandException):

Review Comment:
   This class should be in `databases/ssh_tunnel/commands/exceptions.py` like the others.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org