From 33adac746e28f577789f04cca3b2f4472bf34cea Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Thu, 18 Aug 2022 00:15:13 +0300 Subject: [PATCH] fs: don't import SSHFileSystem --- dvc/fs/__init__.py | 2 -- dvc/machine/backend/base.py | 3 ++- dvc/machine/backend/terraform.py | 5 +++-- dvc/repo/experiments/executor/ssh.py | 3 +-- tests/func/experiments/executor/test_ssh.py | 2 +- tests/unit/fs/test_fs.py | 5 ++--- tests/unit/fs/test_ssh.py | 5 ++--- 7 files changed, 11 insertions(+), 14 deletions(-) diff --git a/dvc/fs/__init__.py b/dvc/fs/__init__.py index 2f46afd766..5137064270 100644 --- a/dvc/fs/__init__.py +++ b/dvc/fs/__init__.py @@ -1,8 +1,6 @@ from urllib.parse import urlparse from dvc_http import HTTPFileSystem, HTTPSFileSystem # noqa: F401 -from dvc_ssh import DEFAULT_PORT as DEFAULT_SSH_PORT # noqa: F401 -from dvc_ssh import SSHFileSystem # noqa: F401 # pylint: disable=unused-import from dvc_objects.fs import utils # noqa: F401 diff --git a/dvc/machine/backend/base.py b/dvc/machine/backend/base.py index 67c1a1f6de..e303c8cdc4 100644 --- a/dvc/machine/backend/base.py +++ b/dvc/machine/backend/base.py @@ -3,7 +3,8 @@ from typing import TYPE_CHECKING, Iterator, Optional if TYPE_CHECKING: - from dvc.fs import SSHFileSystem + from dvc_ssh import SSHFileSystem + from dvc.types import StrPath diff --git a/dvc/machine/backend/terraform.py b/dvc/machine/backend/terraform.py index 0ad1905050..6922b5efa7 100644 --- a/dvc/machine/backend/terraform.py +++ b/dvc/machine/backend/terraform.py @@ -3,8 +3,9 @@ from functools import partial, partialmethod from typing import TYPE_CHECKING, Iterator, Optional +from dvc_ssh import DEFAULT_PORT, SSHFileSystem + from dvc.exceptions import DvcException -from dvc.fs import DEFAULT_SSH_PORT, SSHFileSystem from dvc.utils.fs import makedirs from .base import BaseMachineBackend @@ -68,7 +69,7 @@ def get_executor_kwargs(self, name: str, **config) -> dict: resource = tpi.default_resource(name) return { "host": resource["instance_ip"], - "port": DEFAULT_SSH_PORT, + "port": DEFAULT_PORT, "username": "ubuntu", "fs_factory": partial(_sshfs, dict(resource)), } diff --git a/dvc/repo/experiments/executor/ssh.py b/dvc/repo/experiments/executor/ssh.py index f384c08520..94b235b8ce 100644 --- a/dvc/repo/experiments/executor/ssh.py +++ b/dvc/repo/experiments/executor/ssh.py @@ -5,10 +5,9 @@ from contextlib import contextmanager from typing import TYPE_CHECKING, Callable, Iterable, Optional +from dvc_ssh import SSHFileSystem from funcy import first -from dvc.fs import SSHFileSystem - from ..refs import ( EXEC_BRANCH, EXEC_CHECKPOINT, diff --git a/tests/func/experiments/executor/test_ssh.py b/tests/func/experiments/executor/test_ssh.py index bb84292dda..49ef061e2a 100644 --- a/tests/func/experiments/executor/test_ssh.py +++ b/tests/func/experiments/executor/test_ssh.py @@ -4,9 +4,9 @@ from urllib.parse import urlparse import pytest +from dvc_ssh import SSHFileSystem from dvc_ssh.tests.cloud import TEST_SSH_KEY_PATH, TEST_SSH_USER -from dvc.fs import SSHFileSystem from dvc.repo.experiments.executor.base import ExecutorInfo, ExecutorResult from dvc.repo.experiments.executor.ssh import SSHExecutor from dvc.repo.experiments.refs import EXEC_HEAD, EXEC_MERGE diff --git a/tests/unit/fs/test_fs.py b/tests/unit/fs/test_fs.py index 09014f7c18..0dcffe6356 100644 --- a/tests/unit/fs/test_fs.py +++ b/tests/unit/fs/test_fs.py @@ -1,13 +1,12 @@ import pytest +from dvc_http import HTTPFileSystem, HTTPSFileSystem +from dvc_ssh import SSHFileSystem from dvc.config import RemoteNotFoundError from dvc.fs import ( HDFSFileSystem, - HTTPFileSystem, - HTTPSFileSystem, LocalFileSystem, S3FileSystem, - SSHFileSystem, get_fs_cls, get_fs_config, ) diff --git a/tests/unit/fs/test_ssh.py b/tests/unit/fs/test_ssh.py index 5d0ca116b1..1a379ad086 100644 --- a/tests/unit/fs/test_ssh.py +++ b/tests/unit/fs/test_ssh.py @@ -5,8 +5,7 @@ from unittest.mock import mock_open, patch import pytest - -from dvc.fs import DEFAULT_SSH_PORT, SSHFileSystem +from dvc_ssh import DEFAULT_PORT, SSHFileSystem def test_get_kwargs_from_urls(): @@ -99,7 +98,7 @@ def test_ssh_user(mock_file, config, expected_user): [ ({"host": "example.com"}, 1234), ({"host": "example.com", "port": 4321}, 4321), - ({"host": "not_in_ssh_config.com"}, DEFAULT_SSH_PORT), + ({"host": "not_in_ssh_config.com"}, DEFAULT_PORT), ({"host": "not_in_ssh_config.com", "port": 2222}, 2222), ], )