pysqa.base.remote.RemoteQueueAdapter

pysqa.base.remote.RemoteQueueAdapter#

class pysqa.base.remote.RemoteQueueAdapter(config: dict[str, str], directory: str = '~/.queues', execute_command: ~typing.Callable = <function execute_command>)[source]#

Bases: QueueAdapterWithConfig

A class representing a remote queue adapter.

Parameters:
  • config (dict) – The configuration dictionary.

  • directory (str, optional) – The directory path. Defaults to “~/.queues”.

  • execute_command (Callable, optional) – The execute command function. Defaults to execute_command.

_ssh_host#

The SSH host.

Type:

str

_ssh_username#

The SSH username.

Type:

str

_ssh_known_hosts#

The path to the known hosts file.

Type:

str

_ssh_key#

The path to the SSH key file.

Type:

str

_ssh_ask_for_password#

Flag indicating whether to ask for SSH password.

Type:

bool

_ssh_password#

The SSH password.

Type:

str

_ssh_key_passphrase#

The SSH key passphrase.

Type:

str

_ssh_two_factor_authentication#

Flag indicating whether to use two-factor authentication.

Type:

bool

_ssh_authenticator_service#

The SSH authenticator service.

Type:

str

_ssh_proxy_host#

The SSH proxy host.

Type:

str

_ssh_remote_config_dir#

The remote configuration directory.

Type:

str

_ssh_remote_path#

The remote path.

Type:

str

_ssh_local_path#

The local path.

Type:

str

_ssh_delete_file_on_remote#

Flag indicating whether to delete files on the remote host.

Type:

bool

_ssh_port#

The SSH port.

Type:

int

_ssh_continous_connection#

Flag indicating whether to use continuous SSH connection.

Type:

bool

_ssh_connection#

The SSH connection object.

Type:

None or paramiko.SSHClient

_ssh_proxy_connection#

The SSH proxy connection object.

Type:

None or paramiko.SSHClient

_remote_flag#

Flag indicating whether the adapter is for remote queue.

Type:

bool

convert_path_to_remote(path

str) -> str: Converts a local path to a remote path.

submit_job(queue
Optional[str] = None, job_name: Optional[str] = None, working_directory: Optional[str] = None,

cores: Optional[int] = None, memory_max: Optional[int] = None, run_time_max: Optional[int] = None, dependency_list: Optional[list[str]] = None, command: Optional[str] = None, **kwargs) -> int:

Submits a job to the remote queue.

enable_reservation(process_id

int) -> str: Enables a reservation for a job.

delete_job(process_id

int) -> str: Deletes a job from the remote queue.

get_queue_status(user

Optional[str] = None) -> pandas.DataFrame: Retrieves the queue status.

get_job_from_remote(working_directory

str): Retrieves the results of a calculation executed on a remote host.

transfer_file(file

str, transfer_back: bool = False, delete_file_on_remote: bool = False): Transfers a file to/from the remote host.

__del__()[source]#

Closes the SSH connections.

_check_ssh_connection()[source]#

Checks if an SSH connection is open.

_transfer_files(file_dict

dict, sftp=None, transfer_back: bool = False): Transfers files to/from the remote host.

_open_ssh_connection() paramiko.SSHClient[source]#

Opens an SSH connection.

__init__(config: dict[str, str], directory: str = '~/.queues', execute_command: ~typing.Callable = <function execute_command>)[source]#

Methods

__init__(config[, directory, execute_command])

check_queue_parameters(queue[, cores, ...])

Check the parameters of a queue.

convert_path_to_remote(path)

Converts a local path to a remote path.

delete_job(process_id)

Deletes a job from the remote queue.

enable_reservation(process_id)

Enables a reservation for a job.

get_job_from_remote(working_directory)

Retrieves the results of a calculation executed on a remote host.

get_queue_status([user])

Retrieves the queue status.

get_status_of_job(process_id)

Get the status of a job.

get_status_of_jobs(process_id_lst)

Get the status of multiple jobs.

get_status_of_my_jobs()

Get the status of the user's jobs.

submit_job([queue, job_name, ...])

Submits a job to the remote queue.

transfer_file(file[, transfer_back, ...])

Transfers a file to/from the remote host.

Attributes

config

Get the QueueAdapter configuration.

queue_list

Get the list of available queues.

queue_view

Get the Pandas DataFrame representation of the available queues.

queues

Get the available queues.

remote_flag

Get the value of remote_flag.

ssh_delete_file_on_remote

Get the value of ssh_delete_file_on_remote.

check_queue_parameters(queue: str | None, cores: int = 1, run_time_max: int | None = None, memory_max: int | str | None = None, active_queue: dict | None = None) tuple[float | int | None, float | int | None, float | int | str | None]#

Check the parameters of a queue.

Parameters:
  • queue (str) – The queue to check.

  • cores (int, optional) – The number of cores. Defaults to 1.

  • run_time_max (int, optional) – The maximum run time. Defaults to None.

  • memory_max (int, optional) – The maximum memory. Defaults to None.

  • active_queue (dict, optional) – The active queue. Defaults to None.

Returns:

A list of queue parameters [cores, run_time_max, memory_max].

Return type:

list

property config: dict#

Get the QueueAdapter configuration.

Returns:

The QueueAdapter configuration.

Return type:

dict

convert_path_to_remote(path: str) str[source]#

Converts a local path to a remote path.

Parameters:

path (str) – The local path.

Returns:

The remote path.

Return type:

str

delete_job(process_id: int) str[source]#

Deletes a job from the remote queue.

Parameters:

process_id (int) – The process ID.

Returns:

The output of the delete command.

Return type:

str

enable_reservation(process_id: int) str[source]#

Enables a reservation for a job.

Parameters:

process_id (int) – The process ID.

Returns:

The output of the reservation command.

Return type:

str

get_job_from_remote(working_directory: str)[source]#

Retrieves the results of a calculation executed on a remote host.

Parameters:

working_directory (str) – The local working directory.

get_queue_status(user: str | None = None) DataFrame[source]#

Retrieves the queue status.

Parameters:

user (str, optional) – The username.

Returns:

The queue status.

Return type:

pandas.DataFrame

get_status_of_job(process_id: int) str | None#

Get the status of a job.

Parameters:

process_id (int) – The process ID.

Returns:

The status of the job.results_lst.append(df_selected.values[0])

Return type:

str

get_status_of_jobs(process_id_lst: list[int]) list[str]#

Get the status of multiple jobs.

Parameters:

process_id_lst (list[int]) – List of process IDs.

Returns:

List of job statuses.

Return type:

list[str]

get_status_of_my_jobs() DataFrame#

Get the status of the user’s jobs.

Returns:

The status of the user’s jobs.

Return type:

pandas.DataFrame

property queue_list: list#

Get the list of available queues.

Returns:

The list of available queues.

Return type:

list

property queue_view: DataFrame#

Get the Pandas DataFrame representation of the available queues.

Returns:

The Pandas DataFrame representation of the available queues.

Return type:

pandas.DataFrame

property queues#

Get the available queues.

Returns:

The available queues.

Return type:

Queues

property remote_flag: bool#

Get the value of remote_flag.

Returns:

The value of remote_flag.

Return type:

bool

property ssh_delete_file_on_remote: bool#

Get the value of ssh_delete_file_on_remote.

Returns:

The value of ssh_delete_file_on_remote.

Return type:

bool

submit_job(queue: str | None = None, job_name: str = 'pysqa', working_directory: str | None = None, cores: int = 1, memory_max: int | str | None = None, run_time_max: int | None = None, dependency_list: list[int] | None = None, command: str = '', submission_template: str | Template | None = None, **kwargs) int[source]#

Submits a job to the remote queue.

Parameters:
  • queue (str, optional) – The queue name.

  • job_name (str, optional) – The job name.

  • working_directory (str, optional) – The working directory.

  • cores (int) – The number of cores.

  • memory_max (int, optional) – The maximum memory.

  • run_time_max (int, optional) – The maximum run time.

  • dependency_list (list[int], optional) – The list of job dependencies.

  • command (str) – The command to execute.

Returns:

The process ID of the submitted job.

Return type:

int

transfer_file(file: str, transfer_back: bool = False, delete_file_on_remote: bool = False)[source]#

Transfers a file to/from the remote host.

Parameters:
  • file (str) – The file path.

  • transfer_back (bool, optional) – Flag indicating whether to transfer the file back to the local host.

  • delete_file_on_remote (bool, optional) – Flag indicating whether to delete the file on the remote host.