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 04:21:38 UTC
[GitHub] [superset] hughhhh opened a new pull request, #22148: feat: add create command for ssh tunnels
hughhhh opened a new pull request, #22148:
URL: https://github.com/apache/superset/pull/22148
<!---
Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
Example:
fix(dashboard): load charts correctly
-->
### SUMMARY
<!--- Describe the change below, including rationale and design decisions -->
Create a command to allow users to generate a `SSHTunnel` object to be saved once a `Database` is being commited to the metastore.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
<!--- Skip this if not applicable -->
### TESTING INSTRUCTIONS
<!--- Required! What steps can be taken to manually verify the changes? -->
### ADDITIONAL INFORMATION
<!--- Check any relevant boxes with "x" -->
<!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
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
[GitHub] [superset] hughhhh commented on a diff in pull request #22148: feat(ssh_tunnel): Create command & exceptions
Posted by GitBox <gi...@apache.org>.
hughhhh commented on code in PR #22148:
URL: https://github.com/apache/superset/pull/22148#discussion_r1025694809
##########
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:
`test_database_get_shh_tunnel` to `test_database_get_ssh_tunnel
--
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
[GitHub] [superset] codecov[bot] commented on pull request #22148: feat(ssh_tunnel): Create command & exceptions
Posted by GitBox <gi...@apache.org>.
codecov[bot] commented on PR #22148:
URL: https://github.com/apache/superset/pull/22148#issuecomment-1320552273
# [Codecov](https://codecov.io/gh/apache/superset/pull/22148?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#22148](https://codecov.io/gh/apache/superset/pull/22148?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (7cbe40e) into [create-sshtunnelconfig-tbl](https://codecov.io/gh/apache/superset/commit/44ca56b187e6d659f7f247c00ed70e5071a04c74?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (44ca56b) will **decrease** coverage by `13.65%`.
> The diff coverage is `n/a`.
```diff
@@ Coverage Diff @@
## create-sshtunnelconfig-tbl #22148 +/- ##
===============================================================
- Coverage 67.02% 53.36% -13.66%
===============================================================
Files 1838 1835 -3
Lines 70077 70009 -68
Branches 7571 7571
===============================================================
- Hits 46968 37363 -9605
- Misses 21150 30687 +9537
Partials 1959 1959
```
| Flag | Coverage Δ | |
|---|---|---|
| hive | `52.61% <ø> (ø)` | |
| mysql | `?` | |
| postgres | `?` | |
| presto | `52.51% <ø> (ø)` | |
| python | `52.90% <ø> (-28.48%)` | :arrow_down: |
| sqlite | `?` | |
| unit | `?` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://codecov.io/gh/apache/superset/pull/22148?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [superset/databases/ssh\_tunnel/dao.py](https://codecov.io/gh/apache/superset/pull/22148/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZGF0YWJhc2VzL3NzaF90dW5uZWwvZGFvLnB5) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [superset/utils/dashboard\_import\_export.py](https://codecov.io/gh/apache/superset/pull/22148/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvdXRpbHMvZGFzaGJvYXJkX2ltcG9ydF9leHBvcnQucHk=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [superset/extensions/metastore\_cache.py](https://codecov.io/gh/apache/superset/pull/22148/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZXh0ZW5zaW9ucy9tZXRhc3RvcmVfY2FjaGUucHk=) | `0.00% <0.00%> (-98.08%)` | :arrow_down: |
| [superset/tags/core.py](https://codecov.io/gh/apache/superset/pull/22148/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvdGFncy9jb3JlLnB5) | `4.54% <0.00%> (-95.46%)` | :arrow_down: |
| [superset/key\_value/commands/update.py](https://codecov.io/gh/apache/superset/pull/22148/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQva2V5X3ZhbHVlL2NvbW1hbmRzL3VwZGF0ZS5weQ==) | `0.00% <0.00%> (-90.91%)` | :arrow_down: |
| [superset/key\_value/commands/delete.py](https://codecov.io/gh/apache/superset/pull/22148/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQva2V5X3ZhbHVlL2NvbW1hbmRzL2RlbGV0ZS5weQ==) | `0.00% <0.00%> (-87.88%)` | :arrow_down: |
| [superset/key\_value/commands/delete\_expired.py](https://codecov.io/gh/apache/superset/pull/22148/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQva2V5X3ZhbHVlL2NvbW1hbmRzL2RlbGV0ZV9leHBpcmVkLnB5) | `0.00% <0.00%> (-84.00%)` | :arrow_down: |
| [superset/reports/utils.py](https://codecov.io/gh/apache/superset/pull/22148/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvcmVwb3J0cy91dGlscy5weQ==) | `15.38% <0.00%> (-82.06%)` | :arrow_down: |
| [...set/advanced\_data\_type/plugins/internet\_address.py](https://codecov.io/gh/apache/superset/pull/22148/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvYWR2YW5jZWRfZGF0YV90eXBlL3BsdWdpbnMvaW50ZXJuZXRfYWRkcmVzcy5weQ==) | `16.32% <0.00%> (-79.60%)` | :arrow_down: |
| [superset/utils/pandas\_postprocessing/boxplot.py](https://codecov.io/gh/apache/superset/pull/22148/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvdXRpbHMvcGFuZGFzX3Bvc3Rwcm9jZXNzaW5nL2JveHBsb3QucHk=) | `20.51% <0.00%> (-79.49%)` | :arrow_down: |
| ... and [326 more](https://codecov.io/gh/apache/superset/pull/22148/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
--
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
[GitHub] [superset] eschutho commented on a diff in pull request #22148: feat(ssh_tunnel): Create command & exceptions
Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #22148:
URL: https://github.com/apache/superset/pull/22148#discussion_r1029765434
##########
superset/databases/ssh_tunnel/commands/create.py:
##########
@@ -0,0 +1,48 @@
+# 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.ssh_tunnel.commands.exceptions import SSHTunnelCreateFailedError
+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
+
+ def run(self) -> Model:
+ self.validate()
+
+ try:
+ tunnel = SSHTunnelDAO.create(self._properties, commit=False)
+ except DAOCreateFailedError as ex:
+ raise SSHTunnelCreateFailedError() from ex
+
+ return tunnel
+
+ def validate(self) -> None:
+ # check to make sure the server port is not localhost
Review Comment:
Ok, do we need this validation method then or can we remove it?
--
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
[GitHub] [superset] eschutho commented on a diff in pull request #22148: feat(ssh_tunnel): Create command & exceptions
Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #22148:
URL: https://github.com/apache/superset/pull/22148#discussion_r1026960582
##########
superset/databases/ssh_tunnel/commands/create.py:
##########
@@ -0,0 +1,48 @@
+# 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.ssh_tunnel.commands.exceptions import SSHTunnelCreateFailedError
+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
+
+ def run(self) -> Model:
+ self.validate()
+
+ try:
+ tunnel = SSHTunnelDAO.create(self._properties, commit=False)
+ except DAOCreateFailedError as ex:
+ raise SSHTunnelCreateFailedError() from ex
+
+ return tunnel
+
+ def validate(self) -> None:
+ # check to make sure the server port is not localhost
Review Comment:
can we fill in the validation for this?
--
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
[GitHub] [superset] hughhhh merged pull request #22148: feat(ssh_tunnel): Create command & exceptions
Posted by GitBox <gi...@apache.org>.
hughhhh merged PR #22148:
URL: https://github.com/apache/superset/pull/22148
--
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
[GitHub] [superset] Antonio-RiveroMartnez commented on a diff in pull request #22148: feat(ssh_tunnel): Create command & exceptions
Posted by GitBox <gi...@apache.org>.
Antonio-RiveroMartnez commented on code in PR #22148:
URL: https://github.com/apache/superset/pull/22148#discussion_r1025696796
##########
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:
oh boy! yeah! hahaha trust me I had to read this like 10+ times to realize the mistake. kk thanks!
--
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
[GitHub] [superset] Antonio-RiveroMartnez commented on a diff in pull request #22148: feat(ssh_tunnel): Create command & exceptions
Posted by GitBox <gi...@apache.org>.
Antonio-RiveroMartnez commented on code in PR #22148:
URL: https://github.com/apache/superset/pull/22148#discussion_r1026837607
##########
tests/unit_tests/databases/ssh_tunnel/dao_test.py:
##########
@@ -0,0 +1,40 @@
+# 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.
+
+from typing import Iterator
+
+import pytest
+
+
+def test_create_ssh_tunnel():
+ from superset.databases.ssh_tunnel.dao import SSHTunnelDAO
+ from superset.databases.ssh_tunnel.models import SSHTunnel
+ from superset.models.core import Database
+
+ db = Database(database_name="my_database", sqlalchemy_uri="sqlite://")
+
+ properties = {
+ "server_address": "123.132.123.1",
+ "server_port": "3005",
+ "username": "foo",
+ "password": "bar",
+ }
+
+ result = SSHTunnelDAO.create(properties, commit=True)
Review Comment:
where is it getting the `database_id` from?
--
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
[GitHub] [superset] Antonio-RiveroMartnez commented on a diff in pull request #22148: feat(ssh_tunnel): Create command & exceptions
Posted by GitBox <gi...@apache.org>.
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
[GitHub] [superset] hughhhh commented on a diff in pull request #22148: feat(ssh_tunnel): Create command & exceptions
Posted by GitBox <gi...@apache.org>.
hughhhh commented on code in PR #22148:
URL: https://github.com/apache/superset/pull/22148#discussion_r1025694809
##########
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:
`test_database_get_shh_tunnel` to `test_database_get_ssh_tunnel`
we misspelt ssh lol
--
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
[GitHub] [superset] hughhhh commented on a diff in pull request #22148: feat(ssh_tunnel): Create command & exceptions
Posted by GitBox <gi...@apache.org>.
hughhhh commented on code in PR #22148:
URL: https://github.com/apache/superset/pull/22148#discussion_r1026819059
##########
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:
i removed it, i think the pattern is better since the database_id is the first class citizen
--
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
[GitHub] [superset] hughhhh commented on pull request #22148: feat(ssh_tunnel): Create command & exceptions
Posted by GitBox <gi...@apache.org>.
hughhhh commented on PR #22148:
URL: https://github.com/apache/superset/pull/22148#issuecomment-1324099299
merging to unblock following PRs
> @eschutho let me know if there are any concerns with this approach
--
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
[GitHub] [superset] hughhhh commented on a diff in pull request #22148: feat(ssh_tunnel): Create command & exceptions
Posted by GitBox <gi...@apache.org>.
hughhhh commented on code in PR #22148:
URL: https://github.com/apache/superset/pull/22148#discussion_r1029543154
##########
superset/databases/ssh_tunnel/commands/create.py:
##########
@@ -0,0 +1,48 @@
+# 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.ssh_tunnel.commands.exceptions import SSHTunnelCreateFailedError
+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
+
+ def run(self) -> Model:
+ self.validate()
+
+ try:
+ tunnel = SSHTunnelDAO.create(self._properties, commit=False)
+ except DAOCreateFailedError as ex:
+ raise SSHTunnelCreateFailedError() from ex
+
+ return tunnel
+
+ def validate(self) -> None:
+ # check to make sure the server port is not localhost
Review Comment:
@eschutho going to implement an SSH_MANAGER class to handle this, was talking to @craig-rueda yesterday about the approach and we basically allow users define how the want manage this one their end.
--
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