API documentation

remote_run.run module

Set of functions to allow execution of python functions on a remote host.

class remote_run.run.ExecutionContext(project: ~remote_run.project.Project, num_cpus: int = 1, runner: ~remote_run.runner.Runner = <factory>, scheduling_engine: ~remote_run.scheduling_engine.SchedulingEngine = None, execution: ~remote_run.execution.Execution = <factory>)

Bases: object

Class to define an execution context.

execution: Execution
num_cpus: int = 1
project: Project
runner: Runner
scheduling_engine: SchedulingEngine = None
remote_run.run.remote(execution_context: ExecutionContext, payloads: List[Path] = [])

Decorate a function to be run remotely.

remote_run.run.resolve_payload(payload: Path | Tuple[Path, Path], project: Path)

Resolve the payload path relative to the project path.

remote_run.run.run_remote(func: Callable[[], None], execution_context: ExecutionContext, payloads: List[Path | Tuple[Path, Path]] = [], identifier: Identifier = None)

Run a function on a remote host.

Parameters:
  • func – Function to run on remote machine.

  • execution_context – Context for function execution.

  • payloads – List of payloads for remote run. This is either a path which then gets symlinked to the root of the remote project, or a tuple with the source path and a relative destination path where the payload should be symlinked relative to the project root.

  • identifier – Object holding the project identifier.

Returns:

If no scheduling engine is specified it will return the return argument of the function, otherwise the job id and a function to retrieve the result later is returned.

Return type:

Any

remote_run.run.submit_project(func: Callable[[], None], execution_context: ExecutionContext, identifier: Identifier, payloads: List[Tuple[Path, Path]] = [], python_script_file_name: str = 'fun.py')

Submit a project.

Parameters:
  • func – Function to run on remote machine.

  • execution_context – Context for project execution.

  • identifier – Object holding the project identifier.

  • payloads – List of payloads for remote run. This are tuples with the source path and a relative destination path where the payload should be added relative to the project root.

remote_run.guix module

Utility functions to interact with guix.

remote_run.guix.manifest(dependencies: List[str])

Create a guix manifest file from a list of dependencies.

remote_run.guix.parse_manifest(manifest_file: Path)

Parse a manifest.scm file and return its dependencies as a list.

remote_run.guix.runner(channels: str, dependencies: List[str], executable: str | list[str])

Create a guix runner.

remote_run.packaging module

remote_run.utils module

Utility functions.

remote_run.utils.executable_script(path: Path, content: str)

Create a script file and make it executable.

remote_run.utils.file_bytes_repr(file_path: Path) bytes

Return the bytes representation of a file.

remote_run.utils.hash_list_of_files(files: List[Path])

Create a hash for a list of files.

remote_run.utils.list_all_files_not_git_ignored(project_path: Path) List[Path]

List all file in the project which are not ignored by git.

remote_run.utils.log_subprocess_run(logger: Logger, out: CompletedProcess)

Log stdout of a subprocess.

remote_run.utils.pack_result(result, result_file: Path)

Pack the result depending on the type.

remote_run.utils.python_script_from_function(script_file: Path, function: Callable)

Create a python script from a function.

remote_run.utils.query_git_project_path() Path

Query the project path of a git project.

remote_run.utils.query_remote_home_directory(remote_host: str)

Query home directory on remote host.

remote_run.utils.query_remote_path(path: Path, remote_host: str)

Query path on remote host.

remote_run.utils.query_remote_path_exists(remote_path: Path, remote_host: str)

Query if path exists on remote host.

remote_run.utils.query_remote_python_version(remote_host: str, python_executable: str = 'python3')

Query python version on remote host.

Returns a list with mayor, minor and patchlevel.

remote_run.utils.query_remote_user_name(remote_host: str)

Query user name on remote host.

remote_run.utils.rsync_files(files, location, target)

Copy files from location to target with rsync.

remote_run.utils.run_python_script(run_path: Path, runner_script_file_name: str, python_script_file_name: str, shebang: str = '#!/bin/sh')

Return command to run a python script with a runner script both located in the run_path.

remote_run.utils.unpack_result(result_file: Path)

Unpack the result depending on the file suffix.