Version:

salvus.flow.executors.remote_io_executor

salvus.flow.executors.remote_io_executor salvus flow executors remote_io_executor
Remote I/O functionality.

Classes

LocalSFTPClient

Everything is based on SSH but for the local site its not needed. Thus we implement a custom SFTP client on top of direct file system operations.
SIGNATURE
class LocalSFTPClient(builtins.object):
    def __init__(self): ...

Methods

LocalSFTPClient.close()
Mock method.
SIGNATURE
def close(self) -> None: ...
LocalSFTPClient.get()
Get a remote file.
SIGNATURE
def get(
    self, remotepath: str, localpath: str, callback: typing.Callable | None
) -> None: ...
ARGUMENTS
Required
remotepath
Type:str
Description:
Remote path.
Required
localpath
Type:str
Description:
Local path.
Required
callback
Type:typing.Callable | None
Description:
Callback function.
LocalSFTPClient.getfo()
Get a remote file and copy it to an open file handle.
SIGNATURE
def getfo(
    self, remotepath: str, fl: typing.IO, callback: typing.Callable | None
) -> None: ...
ARGUMENTS
Required
remotepath
Type:str
Description:
Remote path.
Required
fl
Type:typing.IO
Description:
Open file handle.
Required
callback
Type:typing.Callable | None
Description:
Callback function.
LocalSFTPClient.listdir()
List the contents of a directory.
SIGNATURE
def listdir(self, path: str) -> list[str]: ...
ARGUMENTS
Required
path
Type:str
Description:
The path.
LocalSFTPClient.mkdir()
Create directory.
SIGNATURE
def mkdir(self, path: str, mode: int = 511) -> None: ...
ARGUMENTS
Required
path
Type:str
Description:
The path.
Optional
mode
Type:int
Default value:511
Description:
Permission mode.
LocalSFTPClient.put()
Copy a local file to remote site.
SIGNATURE
def put(
    self, localpath: str, remotepath: str, callback: typing.Callable | None
) -> None: ...
ARGUMENTS
Required
localpath
Type:str
Description:
Local file.
Required
remotepath
Type:str
Description:
Remote path.
Required
callback
Type:typing.Callable | None
Description:
Callback function.
LocalSFTPClient.putfo()
Put the contents of an open file handle to a remote path.
SIGNATURE
def putfo(
    self, fl: typing.IO, remotepath: str, callback: typing.Callable | None
) -> None: ...
ARGUMENTS
Required
fl
Type:typing.IO
Description:
Open file handle.
Required
remotepath
Type:str
Description:
Remote path.
Required
callback
Type:typing.Callable | None
Description:
Callback function.
LocalSFTPClient.rmdir()
Remove a directory.
SIGNATURE
def rmdir(self, path: str) -> None: ...
ARGUMENTS
Required
path
Type:str
Description:
The path.
LocalSFTPClient.stat()
Return stat().
SIGNATURE
def stat(self, path: str) -> os.stat_result: ...
ARGUMENTS
Required
path
Type:str
Description:
The path.
Unlink the path.
SIGNATURE
def unlink(self, path: str) -> None: ...
ARGUMENTS
Required
path
Type:str
Description:
The path.

LocalSSHClient

Fake "local" SSH client.
SIGNATURE
class LocalSSHClient(builtins.object):
    def __init__(self): ...

Methods

LocalSSHClient.close()
Mock method.
SIGNATURE
def close(self) -> None: ...
LocalSSHClient.connect()
Mock method.
SIGNATURE
def connect(self) -> None: ...
LocalSSHClient.exec_command()
Mock method.
SIGNATURE
def exec_command(self) -> None: ...
LocalSSHClient.load_system_host_keys()
Mock method.
SIGNATURE
def load_system_host_keys(self) -> None: ...
LocalSSHClient.open_sftp()
Mock method.
SIGNATURE
def open_sftp(self) -> None: ...
LocalSSHClient.set_missing_host_key_policy()
Mock method.
SIGNATURE
def set_missing_host_key_policy(self) -> None: ...

OSType

Enumerate the type of operating system.
SIGNATURE
class OSType(enum.Enum):
    def __init__(self): ...

RemoteIOExecutor

Class to encapsulate SSH/SFTP client initialization and remote I/O functionality.
Not useful on its own - does require self.name and self.config to be available.
SIGNATURE
class RemoteIOExecutor(builtins.object):
    def __init__(self): ...

Properties

  • file_path_type(type[pathlib.PurePosixPath | pathlib.PureWindowsPath])-Returns the type of file paths for the given site.
  • home_dir(pathlib.PurePosixPath | pathlib.PureWindowsPath)-The home directory.
  • os_type(OSType)-Returns the type of the operating system. Subclasses can overwrite this.
  • sftp_client(paramiko.sftp_client.SFTPClient | LocalSFTPClient)-Get the sftp client instance. Will be initialized upon the first access.
  • ssh_client(paramiko.client.SSHClient | LocalSSHClient)-Get the ssh client instance. Will be initialized upon the first access.

Methods

RemoteIOExecutor.execute_command()
Execute the command.
SIGNATURE
def execute_command(
    self,
    command: str,
    assert_ok: bool = True,
    environment: dict[str, str] | None = None,
) -> tuple[int, list[str], list[str]]: ...
ARGUMENTS
Required
command
Type:str
Description:
The command to run as a string.
Optional
assert_ok
Type:bool
Default value:True
Description:
Raise if the command does not exist with a code of 0.
Optional
environment
Type:dict[str, str] | None
Default value:None
Description:
Environment variables to be set for this command.
RemoteIOExecutor.is_folder_writeable()
Return True if the user has write permissions in the chosen folder.
SIGNATURE
def is_folder_writeable(self, path: _RemotePathInputType) -> bool: ...
ARGUMENTS
Required
path
Type:_RemotePathInputType
Description:
Path on the remote machine.
RemoteIOExecutor.remote_exists()
Check if a remote file or directory exists.
SIGNATURE
def remote_exists(self, path: _RemotePathInputType) -> bool: ...
ARGUMENTS
Required
path
Type:_RemotePathInputType
Description:
Path to check.
RemoteIOExecutor.remote_get()
Get a remote file.
SIGNATURE
def remote_get(
    self,
    remotepath: _RemotePathInputType,
    localpath: io.BytesIO | pathlib.Path,
    show_progressbar: bool = False,
) -> None: ...
ARGUMENTS
Required
remotepath
Type:_RemotePathInputType
Description:
Remote file to get.
Required
localpath
Type:io.BytesIO | pathlib.Path
Description:
Local path to save to Can be a file or a file like object.
Optional
show_progressbar
Type:bool
Default value:False
Description:
Show a progressbar or not.
RemoteIOExecutor.remote_listdir()
List the contents of a remote directory.
Just dispatches to the underlying representation.
SIGNATURE
def remote_listdir(self, path: _RemotePathInputType) -> list[str]: ...
ARGUMENTS
Required
path
Type:_RemotePathInputType
Description:
Remote path whose contents to list.
RemoteIOExecutor.remote_mkdir()
Create a directory on the remote or local machine.
SIGNATURE
def remote_mkdir(
    self, path: _RemotePathInputType, mode: int = 511
) -> None: ...
ARGUMENTS
Required
path
Type:_RemotePathInputType
Description:
Directory to create.
Optional
mode
Type:int
Default value:511
Description:
Permissions for the new directory.
RemoteIOExecutor.remote_put()
Copy a local file to a remote path.
SIGNATURE
def remote_put(
    self,
    localpath: io.BytesIO | pathlib.Path,
    remotepath: _RemotePathInputType,
    show_progressbar: bool = False,
) -> None: ...
ARGUMENTS
Required
localpath
Type:io.BytesIO | pathlib.Path
Description:
Local file to copy. Can be a file like object.
Required
remotepath
Type:_RemotePathInputType
Description:
Where to copy to.
Optional
show_progressbar
Type:bool
Default value:False
Description:
Show a progressbar or not.
RemoteIOExecutor.remote_rmdir()
Remotely and recursively delete a remote folder and its contents.
SIGNATURE
def remote_rmdir(
    self, path: _RemotePathInputType, verbosity: int = 1
) -> None: ...
ARGUMENTS
Required
path
Type:_RemotePathInputType
Description:
Remote path to delete.
Optional
verbosity
Type:int
Default value:1
Description:
Verbosity level.
RemoteIOExecutor.safe_remote_rmdir()
Convenience wrapper that optionally allows the remote_rmdir() command to fail. Useful for some networked file systems.
SIGNATURE
def safe_remote_rmdir(
    self, path: _RemotePathInputType, allow_failure: bool, verbosity: int = 1
) -> None: ...
ARGUMENTS
Required
path
Type:_RemotePathInputType
Description:
Remote path to delete.
Required
allow_failure
Type:bool
Description:
Whether to allow failure or not.
Optional
verbosity
Type:int
Default value:1
Description:
Verbosity level.
PAGE CONTENTS