kunefe
Documentation about kunefe.
Submodules
Package Contents
Classes
Submit jobs to SLURM cluster. |
- class kunefe.Kunefe(username: str, hostname: str, port: int)[source]
Submit jobs to SLURM cluster.
- ssh_client
ssh client to connect and run commands on the remote system.
- sftp_client
sftp client to copy files from and to a remote system.
- set_password() str [source]
Sets user password. The password is not echoed.
- Returns:
password of the user
- Return type:
password (str)
- set_ssh_client() paramiko.SSHClient [source]
Creates an SSH client and connects to remote system.
- Returns:
ssh client
- Return type:
ssh_client (paramiko.SSHClient)
- connect_remote() None [source]
Creates an ssh and sftp clients, prompts for user password and connects to the remote host.
- Returns:
None
- create_remote_folder(remote_folder: str) None [source]
Create a folder in the remote system.
- Parameters:
remote_folder (str) – path of the folder to be created on the remote system.
- Returns:
None
- get_files(remote_folder: str, local_folder: str = './') None [source]
Get files from the remote system.
- put_files(remote_folder: str = '~', local_folder: str = './', verbose: bool = False) None [source]
Copy files to the remote system.
- submit_job(job_file: str, verbose: bool = False) Tuple[int, str, str, str] [source]
Submit job to SLURM cluster.
- build_apptainer_image(docker_image: str, sif_file_name: str = 'app.sif') bool [source]
Builds an Apptainer image from a Docker image.
- install_apptainer_on_remote(install_path: str = '~') bool [source]
Installs Apptainer on a remote system in unprivileged mode.
- check_local_command_exists(command: str) bool [source]
Check whether command is on PATH and marked as executable.
- Parameters:
command (str) – a command to be checked.
- Returns:
True if command exists. Otherwise False.
- Return type:
Examples
>>> from kunefe import Kunefe >>> kunefe = Kunefe(username="xenon", hostname="localhost", port=10022) >>> kunefe.check_local_command_exists(command='ls') True >>> kunefe.check_local_command_exists(command='thisdoesnotexist') False
- check_required_tools(command_list: list[str]) bool [source]
Check whether all required commands are available.
- Parameters:
- Returns:
True if all the tools exist. Otherwise False.
- Return type:
Examples
>>> from kunefe import Kunefe >>> kunefe = Kunefe(username="xenon", hostname="localhost", port=10022) >>> kunefe.check_required_tools(['ls', 'rsync', 'cp']) True >>> kunefe.check_required_tools(['docker', 'rsync', 'bsxcommand']) False
- generate_job_script(job_name: str, sif_file_path: str, command: str, env_vars: str, job_time: str, job_file_path: str = './', template_name: str = 'generic') None [source]
Generate a batch script file for job submission.
- Parameters:
job_name (str) – name of the job to be used when submitting.
sif_file_path (str) – path of the Apptainer image.
command (str) – a command to be executed using Apptainer image.
env_vars (str) – environment variables to be used when submitting the job.
job_time (str) – time limit for the job.
job_file_path (str, optional) – path to save the generated batch job script. Defaults to ‘./’.
template_name (str, optional) – name of the template to be used. Defaults to ‘generic’.
- Returns:
None
- run_remote_command(command: str, timeout: int = 5, flush: bool = False, show_stdout: bool = False) list[str] [source]
Run a command on a remote system.
- Parameters:
- Returns:
stdin, stdout, stderr
- Return type: