mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-23 07:18:27 +01:00
* machine: move to tpi[ssh] - depends on https://github.com/iterative/tpi * lazy import tpi * fix lint warning Co-authored-by: Peter Rowlands <[email protected]>
30 lines
902 B
Python
30 lines
902 B
Python
from contextlib import contextmanager
|
|
from typing import TYPE_CHECKING, Iterator, Optional
|
|
|
|
from tpi import TerraformProviderIterative, terraform
|
|
|
|
from dvc.fs.ssh import SSHFileSystem
|
|
|
|
if TYPE_CHECKING:
|
|
from dvc.repo.experiments.executor.base import BaseExecutor
|
|
|
|
|
|
class TerraformBackend(terraform.TerraformBackend):
|
|
def get_executor(
|
|
self, name: Optional[str] = None, **config
|
|
) -> "BaseExecutor":
|
|
raise NotImplementedError
|
|
|
|
@contextmanager
|
|
def get_sshfs( # pylint: disable=unused-argument
|
|
self, name: Optional[str] = None, **config
|
|
) -> Iterator["SSHFileSystem"]:
|
|
resource = self._default_resource(name)
|
|
with TerraformProviderIterative.pemfile(resource) as pem:
|
|
fs = SSHFileSystem(
|
|
host=resource["instance_ip"],
|
|
user="ubuntu",
|
|
keyfile=pem,
|
|
)
|
|
yield fs
|