class SshClient(FileReader):
Constructor: SshClient(server, username, password, sftp, port)
SSH-based file reader that extends FileReader to handle file operations over SSH/SFTP. Enables reading, writing, listing, and transferring files on a remote server securely.
| Method | __del__ |
Destructor that closes SSH and SFTP connections and cleans up resources. |
| Method | __init__ |
Initialize SSH and SFTP connection parameters. |
| Method | download |
Download a remote file via SFTP. |
| Method | filter |
Filter SSH command output using predefined patterns. |
| Method | get |
Get the size of a file on the remote server. |
| Method | isfile |
Check whether the given remote path points to a file. |
| Method | listdir |
List files and directories at a remote path. |
| Method | load |
Download an h5ad file from the remote server in chunks. |
| Method | run |
Run a command on the remote server via SSH. |
| Method | write |
Write data (string or DataFrame) to a file on the remote server. |
| Instance Variable | filter |
Undocumented |
| Instance Variable | filtered |
Undocumented |
| Instance Variable | password |
Undocumented |
| Instance Variable | port |
Undocumented |
| Instance Variable | remote |
Undocumented |
| Instance Variable | server |
Undocumented |
| Instance Variable | sftp |
Undocumented |
| Instance Variable | sftp |
Undocumented |
| Instance Variable | sftp |
Undocumented |
| Instance Variable | ssh |
Undocumented |
| Instance Variable | username |
Undocumented |
| Method | _connect |
Establish SSH and SFTP connections using Paramiko. |
| Method | _create |
Undocumented |
| Method | _load |
Load SSH output filter patterns from YAML configuration. |
| Method | _read |
Undocumented |
| Method | _read |
Undocumented |
Inherited from FileReader:
| Method | clean |
Deletes a temporary file if it exists. |
| Method | decode |
Decodes content based on file type, returning a DataFrame or raw string. |
| Method | get |
Extracts the file extension from a given path. |
| Method | is |
Checks if the reader is set to remote mode. |
| Method | read |
Unified file reader for local or remote paths. :param path: File path. :param type: Optional file type override (generic types: pdf, image, text, csv, zip). :param as_dataframe: Whether to parse into a DataFrame... |
| Method | read |
File reader into a dataframe for local and remote paths :param path: File path. :param type: Optional file type override (generic types: pdf, image, text, csv, zip). :param as_dataframe: Force a parsing into a DataFrame... |
| Method | read |
Reads an H5AD file using `anndatareader`. |
| Method | read |
Reads a VCF (Variant Call Format) file using `pysam`. |
| Method | set |
Sets the `clean_on_destruction` flag. |
| Instance Variable | clean |
Undocumented |
| Instance Variable | files |
Undocumented |
| Method | _is |
Undocumented |
| Method | _is |
Undocumented |
| Method | _is |
Undocumented |
pyalma.fileReader.FileReader.__del__Destructor that closes SSH and SFTP connections and cleans up resources.
pyalma.fileReader.FileReader.__init__Initialize SSH and SFTP connection parameters.
:param server: Main SSH server address. :type server: str :param username: SSH username. :type username: str :param password: SSH password. :type password: str :param sftp: SFTP host (defaults to `server` if not specified). :type sftp: str
Download a remote file via SFTP.
:param remote_path: Path on the remote server. :type remote_path: str :param local_path: Local destination path. :type local_path: str
Filter SSH command output using predefined patterns.
:param output: Raw output from SSH command. :type output: str :return: Filtered output string. :rtype: str
Get the size of a file on the remote server.
:param path: Remote file path. :type path: str :return: Size in bytes, or None if error. :rtype: int | None
pyalma.fileReader.FileReader.isfileCheck whether the given remote path points to a file.
:param path: Remote path. :type path: str :return: True if path is a file. :rtype: bool
pyalma.fileReader.FileReader.listdirList files and directories at a remote path.
:param path: Remote directory path. :type path: str :return: Tuple of (directories, files). :rtype: tuple[list[str], list[str]]
Download an h5ad file from the remote server in chunks.
:param path: Remote file path. :type path: str :param local_path: Destination on local machine. :type local_path: str :return: Local path of the saved file or None if failed. :rtype: str | None
Run a command on the remote server via SSH.
:param command: Command to execute. :type command: str :return: Dictionary with 'output' and 'err' keys. :rtype: dict
Write data (string or DataFrame) to a file on the remote server.
:param data: The data to write. :type data: pd.DataFrame | str :param remote_path: Destination path on the remote server. :type remote_path: str :param file_format: Format to use ('csv' supported for DataFrames). :type file_format: str :raises ValueError: If unsupported DataFrame format is specified. :raises TypeError: If data is not string or DataFrame.
Establish SSH and SFTP connections using Paramiko.
:raises ConnectionError: If authentication or connection fails.