remotescript package

Module contents

A package for running scripts on remote machines.

Functions

check_bash

Check if bash is installed on the remote machine.

run_script

Run a script on a remote machine.

set_log_level

Set the log level for the remotescript package.

remotescript.check_bash(client: SSHClient) str | None

Check if bash is available on the remote machine.

Parameters:

client (paramiko.SSHClient) – The client to check for bash on.

Returns:

The version of bash found.

Return type:

str | None

remotescript.run_script(machine_name: str, hostname: str, user: str, password: str, port: int | None, script_path: Path, output_dir_path: Path, deps: Path, datafiles: list[Path] | None = None, dep_scripts: list[Path] | None = None, dep_dirs: list[Path] | None = None, timeout: int = 5, *, transfer_run_dir: bool | None = None, use_system_site_packages: bool | None = None, no_venv: bool | None = None) bool

Run the script on the remote machine.

Parameters:
  • machine_name (str) – The name of the machine.

  • hostname (str) – The hostname of the machine.

  • user (str) – The user to connect as.

  • password (str) – The password to connect with.

  • port (int) – The port to connect on.

  • script_path (Path) – The path to the script to run.

  • output_dir_path (Path) – The path to the output directory.

  • datafiles (list[Path]) – The data files to transfer.

  • deps (Path | None) – The dependencies to install.

  • dep_scripts (list[Path] | None) – The dependency scripts to run.

  • dep_dirs (list[Path] | None) – The dependency directories to transfer.

  • timeout (int) – The timeout for the connection.

  • transfer_run_dir (bool | None) – Whether to transfer the run directory back to the host. If None, the default is False.

  • use_system_site_packages (bool | None) – Whether to use the system site packages. If None, the default is False. This is useful when specific packages are needed, which may only be installed on the overall system. For example, PyTorch with CUDA on Jetson devices.

  • no_venv (bool | None) – Whether to use a virtual environment. This can be useful when script has no dependencies. If None, the default is False. If there are dependencies, they will be installed to the system site packages. Use caution when setting this to True.

Returns:

True if the script ran successfully, False otherwise.

Return type:

bool

remotescript.set_log_level(level: str) None

Set the log level for the remotescript package.

Parameters:

level (str) – The log level to set. One of “DEBUG”, “INFO”, “WARNING”, “ERROR”, “CRITICAL”.

Raises:

ValueError – If the level is not one of the allowed values.