autosubmit.platform#
- class autosubmit.platforms.platform.CopyQueue(maxsize: int = -1, ctx: Any = None)#
Bases:
QueueQueue used to send jobs to the log recovery process.
- static job_data(job: Job) LogRecoveryJobData#
Build the lightweight payload stored in the recovery queue for a job.
- Parameters:
job – The job to serialize.
- Returns:
A dictionary with the information required by the recovery process.
- class autosubmit.platforms.platform.LogRecoveryJobData#
Bases:
TypedDictSerialized payload stored in the log recovery queue for a single job.
- class autosubmit.platforms.platform.Platform(expid: str, name: str, config: dict, auth_password: str | list[str] | None = None)#
Bases:
ABCClass to manage the connections to the different platforms.
- Attributes:
EXECUTION_MODE: The execution mode (DIRECT or BATCH). TYPE: The platform type. expid: The experiment identifier associated with this platform. _name: The platform name. config: The platform configuration dictionary. pw: Optional authentication password (e.g., for 2FA). has_scheduler: Whether the platform is a scheduler wrapper (e.g. ECACCESS wrapping SLURM/PBS).
- add_job_to_log_recover(job, as_conf: AutosubmitConfig) bool#
Queue a job so its logs and stats can be recovered by the recovery process.
When the recovery process is dead it is restarted (re-queueing the jobs that were still pending) instead of silently dropping the job. While the process is unavailable, the logs are recovered inline when
RUNTIME.LOG_RECOVERY.INLINE_FALLBACKis enabled.- Parameters:
job – Job whose logs have to be recovered.
as_conf – Experiment configuration.
- Returns:
Truewhen the job was queued (or recovered inline),Falseotherwise.
- add_parameters(as_conf: AutosubmitConfig)#
Add parameters for the current platform to the given parameters list.
- Parameters:
as_conf – autosubmit config object
- property allow_arrays: bool#
Whether array jobs are allowed.
- Autosubmit-group:
JOB
- property allow_python_jobs: bool#
Whether python jobs are allowed.
- Autosubmit-group:
JOB
- property allow_wrappers: bool#
Whether wrappers are allowed.
- Autosubmit-group:
JOB
- property budget#
Platform budget.
- check_all_jobs(job_list: list[Job], as_conf: AutosubmitConfig, retries: int = 5)#
Checks jobs running status
- Parameters:
job_list – list of jobs
as_conf – config
retries – retries
- clean_log_recovery_process(keep_pending_jobs: bool = False) None#
Cleans the log recovery process variables.
This method sets the cleanup event to signal the log recovery process to finish, waits for the process to join with a timeout, and then resets all related variables.
- Parameters:
keep_pending_jobs – When
Truethe jobs pending recovery are preserved so a new process can take them over (used while respawning). WhenFalse(default) all the log recovery state, including pending jobs, is reset.
- compress_file(file_path: str) str | None#
Compress a file.
- Parameters:
file_path – file path
- Returns:
The path to the compressed file. None if compression failed.
- confirm_done_jobs_via_stat(job_list: list) dict[str, Status]#
Confirm that jobs marked as done are actually completed by checking their STAT files.
- Parameters:
job_list – List of jobs to confirm.
- Returns:
List of jobs that are confirmed as completed.
- connect(as_conf: AutosubmitConfig, reconnect: bool = False, log_recovery_process: bool = False) None#
Establishes an SSH connection to the host.
- Parameters:
as_conf – The Autosubmit configuration object.
reconnect – Indicates whether to attempt reconnection if the initial connection fails.
log_recovery_process – Specifies if the call is made from the log retrieval process.
- Returns:
None
- delete_file(filename: str) bool#
Deletes a file from this platform.
- Parameters:
filename – file name
- Returns:
True if successful or file does not exist
- delete_previous_run_files_by_job_names(job_names: list[str]) None#
Delete the COMPLETED and FAILED files for the given job names from the remote log directory.
- Parameters:
job_names – List of job names whose COMPLETED and FAILED files should be deleted.
- delete_previous_stat_files_by_job_names(job_names: list[str]) None#
Delete all previous STAT files for the given job names from the remote log directory.
- Parameters:
job_names – List of job names whose STAT files should be deleted.
- property exclusivity#
True if you want to request exclusivity nodes.
- get_checkpoint_files(job: Job)#
Get all the checkpoint files of a job.
- Parameters:
job – Get the checkpoint files
- get_completed_job_names(job_names: list[str] | None = None) list[str]#
Get the names of the completed jobs on this platform.
- Parameters:
job_names – List of job names to check. If None, all jobs will be checked.
- Returns:
List of completed job names.
- get_file(filename: str, must_exist: bool = True, relative_path: str = '', ignore_log: bool = False, wrapper_failed: bool = False) bool#
Copies a file from the current platform to experiment’s tmp folder
- Parameters:
wrapper_failed
ignore_log
filename – file name
must_exist – If True, raises an exception if file can not be copied
relative_path – relative path inside tmp folder
- Returns:
True if file is copied successfully, false otherwise
- get_files(files: list[str], must_exist: bool = True, relative_path: str = '') None#
Copies some files from the current platform to experiment’s tmp folder.
- Parameters:
files – file names
must_exist – If True, raises an exception if file can not be copied
relative_path – relative path inside tmp folder
- Returns:
True if file is copied successfully, false otherwise
- get_files_path() Path#
The platform’s LOG directory.
- Returns:
platform’s LOG directory
- Return type:
str
- get_logs_files(exp_id: str, remote_logs: tuple[str, str]) None#
Get the given LOGS files.
- Parameters:
exp_id – experiment id
remote_logs – names of the log files
- get_remote_log_dir() Path#
Get the variable remote_log_dir that stores the directory of the experiment’s log.
- Returns:
The remote_log_dir variable.
- property host#
Platform url.
- property hyperthreading#
True if hyperthreading is enabled on this platform.
- join_new_process() None#
Check whether the recovery process is running and reap it when it is not.
Process.is_alive()callspoll().poll()callsos.waitpid(pid, os.WNOHANG), which reaps the child if it already exited. Reaping throughmultiprocessingkeepsis_alive()andexitcodeaccurate. Reaping with a rawos.waitpidoutsidemultiprocessingleaves the process object believing the child is still alive forever. The raw reap makespoll()receiveECHILDand returnNone, sois_alive()keeps returningTrue.
- property log_recovery_process_alive: bool#
Whether the log recovery process exists and is running.
- move_file(src: str, dest: str) bool#
Moves a file on the platform.
- Parameters:
src – source name
dest – destination name
- property name#
Platform name.
- property partition: str#
Partition to use for jobs.
- Returns:
queue’s name
- static prepare_dry_run_if_applicable(job_list: JobList, package: JobPackageBase, only_wrappers: bool, inspect: bool, as_conf: AutosubmitConfig) None#
Dry-run preparation of a package to emulate that the package was submitted, without following the normal submission flow.
- Parameters:
package – Package being prepared for inspect or wrapper-only mode.
only_wrappers – If
True, prepare wrapper metadata without following the normal submission flow.inspect – If
True, prepare package metadata for inspect mode.
- Raises:
Exception – Propagate any exception raised while creating wrapper job metadata or saving the package.
- prepare_submission(as_conf: AutosubmitConfig, job_list: JobList, packages_to_submit: list[JobPackageBase], inspect: bool = False, only_wrappers: bool = False) tuple[dict[str, dict[str, JobPackageBase]], dict[str, dict[str, JobPackageBase]]]#
Prepare job packages for submission on the current platform.
Log the number of ready jobs, optionally initialize the platform submit script, and process each package selected for submission. Depending on the
inspectandonly_wrappersflags, this method updates wrapper metadata, generates job scripts, transfers files to the platform, and collects the jobs prepared for later submission handling.- Parameters:
as_conf – Autosubmit configuration for the current experiment.
job_list – Job container used to inspect ready jobs and register wrapper information.
packages_to_submit – Packages built for this platform and ready to be prepared.
inspect – If
True, prepare packages for inspect mode without generating the platform submit script or sending files.only_wrappers – If
True, prepare only wrapper-related metadata and skip the regular package submission flow.
- Raises:
Exception – Propagate any exception raised while preparing packages, generating scripts, or transferring files.
- Returns:
A list containing the jobs gathered while preparing the given packages for submission.
- property project#
Platform project.
- property project_dir#
Platform’s project folder path.
- property queue: str#
Queue to use for jobs.
- Returns:
queue’s name
- read_file(src: str, max_size: int | None = None) bytes | None#
Read file content as bytes. If max_size is set, only the first max_size bytes are read.
- Parameters:
src – file path
max_size – maximum size to read
- read_jobid_from_remote_log(remote_path: str) int | None#
Reads the JOBID from the first line of a remote log file.
- Parameters:
remote_path – full remote path to the log file
- Returns:
job ID if found, None otherwise
- recover_job_log(jobs_db_manager: JobsDbManager) None#
Recover the log files of the jobs waiting in the recovery queue.
A failing job is logged, the connection is restored and the queue keeps draining. The job is retried later by the normal recovery scan.
Uses
self._as_confbecause the recovery process reloads the configuration before draining the queue.
- recover_log_inline(job, as_conf: AutosubmitConfig) bool#
Recover the given in-memory job’s logs in the main process and persist the result.
Used when the recovery threads are disabled for this platform.
- Parameters:
job – Job to recover.
as_conf – Experiment configuration.
- Returns:
Truewhen the inline recovery was attempted.Job.recover_loguses it to incrementlog_recovery_call_count.
- recover_platform_job_logs() None#
Recover the logs of the jobs that have been submitted.
When this is executed as a process, the exit is controlled by the work_event and cleanup_event of the main process. The configuration is reloaded before draining the queue. The child sets
_log_recovery_readyafter a verified connection and exits with a non-zero code on failure, so the parent can distinguish a normal idle exit from a crash.
- remove_checkpoint_file(filename)#
Removes CHECKPOINT files from remote.
- Parameters:
filename – file name to delete.
- Returns:
True if successful, False otherwise
- remove_completed_file(job_name: str) bool#
Removes COMPLETED files from remote.
- Parameters:
job_name – name of job to check
- Returns:
True if successful, False otherwise
- remove_stat_file(job: Job) bool#
Removes STAT files from remote.
- Parameters:
job – Job to check.
- Returns:
True if the file was removed, False otherwise.
- classmethod remove_workers(event_worker: Event) None#
Remove the given even worker from the list of workers in this class.
- property reservation#
You can configure your reservation id for the given platform.
- restore_connection(as_conf: AutosubmitConfig, log_recovery_process: bool = False) None#
Restores the SSH connection to the platform.
- Parameters:
as_conf – The Autosubmit configuration object used to establish the connection.
log_recovery_process – Indicates that the call is made from the log retrieval process.
- property root_dir#
Platform’s experiment folder path.
- property scratch#
Platform’s scratch folder path.
- send_cleanup_signal() None#
Sends a cleanup signal to the log recovery process if it is alive. This function is executed by the atexit module
- send_file(filename: str, check=True) bool#
Sends a local file to the platform.
- Parameters:
filename – The name of the file to send.
check – Whether the platform must perform tests (e.g. for permission).
- property serial_partition: str#
Partition to use for serial jobs.
- Returns:
partition’s name
- property serial_queue: str#
Queue to use for serial jobs.
- Returns:
queue’s name
- should_run_log_recovery(as_conf: AutosubmitConfig | None) bool#
Whether a separate log recovery process is expected for this platform.
- Parameters:
as_conf – Experiment configuration.
- Returns:
Truewhen recovery threads are enabled and the command isrun.
- spawn_log_retrieval_process(as_conf: AutosubmitConfig | None) bool#
Spawn a process to recover the logs of the jobs completed on this platform.
- Parameters:
as_conf – Configuration object for the platform.
- Returns:
Truewhen a live recovery process is running.
- try_respawn_log_recovery_process(as_conf: AutosubmitConfig) bool#
Ensure a log recovery process is running when one is expected.
Safe to call periodically: it only restarts a dead process and respects the retry backoff configured under
RUNTIME.LOG_RECOVERY.A successful spawn only proves that the child started, not that it stayed alive. The child sets
_log_recovery_readyafter a verified connection. A child that died without setting the event is a startup failure. A child that set the event but exited non-zero is a post-init crash. A child that set the event and exited zero is a normal idle or cleanup exit.Without this distinction, every crash would reset the failure counter because spawn returns True, so
CONSECUTIVE_MAX_RESTARTSandRETRY_DELAYwould never engage and the process would respawn in a tight crash loop.- Parameters:
as_conf – Experiment configuration.
- Returns:
Truewhen a live recovery process is running.
- property user#
Platform user.
- wait_for_work() bool#
Waits until there is work, or the keep alive timeout is reached.
- Returns:
True if there is work to process, False otherwise.
- write_jobid(jobid: str, complete_path: str) None#
Writes Job id in an out/err file.
- Parameters:
jobid – job id
complete_path – complete path to the file, includes filename
- autosubmit.platforms.platform.recover_platform_job_logs_wrapper(platform: Platform, recovery_queue: CopyQueue, worker_event: Event, cleanup_event: Event, ready_event: Event, as_conf: AutosubmitConfig) None#
Wrapper function to recover platform job logs.
- Parameters:
platform – The platform object responsible for managing the connection and job recovery.
recovery_queue – A multiprocessing queue is used to store jobs for recovery.
worker_event – An event to signal work availability.
cleanup_event – An event to signal clean-up operations.
ready_event – An event the child sets once it has connected successfully.
as_conf – The Autosubmit configuration object containing experiment data.
- class autosubmit.platforms.ecplatform.EcPlatform(expid, name, config, scheduler)#
Bases:
ParamikoPlatformClass to manage queues with ecaccess
- Parameters:
expid – experiment’s identifier
scheduler – scheduler to use
- cancel_jobs(job_ids: list[str]) None#
Cancel ecaccess jobs by their IDs.
- Parameters:
job_ids – List of ecaccess job IDs to cancel.
- check_remote_log_dir() None#
Create the remote log directory and all required parent directories.
ecaccess-file-mkdirhas no-poption, so each intermediate path level must be created in sequence. Failures for levels that already exist are silenced; only a failure on the final LOG directory is reported.- Raises:
AutosubmitError – If the log directory cannot be created.
- check_remote_permissions() bool#
Checks if the necessary permissions are in place on the remote host. There is no mkdir -p equivalent in ecaccess-file-mkdir. So we need to check permissions for each level of the path separately.
- confirm_done_jobs_via_stat(job_list: list) dict[str, Status]#
Confirm job statuses via STAT files using ecaccess commands.
Overrides the base
awk-based implementation because EcPlatform runs commands locally via subprocess and cannot read remote files directly.STAT format: submit_time (L0), start_time (L1), end_time (L2), status (L3). A single numeric line means the job is submitted but not yet started → QUEUING.
- Parameters:
job_list – Jobs to confirm.
- Returns:
Mapping of job names to resolved statuses.
- connect(as_conf: AutosubmitConfig, reconnect: bool = False, log_recovery_process: bool = False) None#
Establishes an SSH connection to the host.
- Parameters:
as_conf – The Autosubmit configuration object.
reconnect – Indicates whether to attempt reconnection if the initial connection fails.
log_recovery_process – Specifies if the call is made from the log retrieval process.
- Returns:
None
- delete_file(filename: str) bool#
Deletes a file from this platform
- Parameters:
filename – file name
- Returns:
True if successful or file does not exist
- delete_previous_run_files_by_job_names(job_names: list[str]) None#
Delete COMPLETED and FAILED marker files for the given job names using ecaccess.
Overrides the base SSH
find-based implementation because EcPlatform runs commands locally via subprocess, not over SSH.- Parameters:
job_names – Job names whose COMPLETED and FAILED files should be deleted.
- delete_previous_stat_files_by_job_names(job_names: list[str]) None#
Delete all STAT marker files for the given job names using ecaccess.
Lists the remote log directory via
ecaccess-file-dirand removes any matching{name}_STAT_*files one at a time. Overrides the base SSHfind-based implementation because EcPlatform runs commands locally.- Parameters:
job_names – Job names whose STAT files should be deleted.
- get_check_all_jobs_cmd(jobs_id)#
Return the batch job-list command for ecaccess.
ecaccess-job-listwithout arguments lists all active jobs for the user, so a single call covers every job in jobs_id.- Parameters:
jobs_id – Comma-separated job IDs (ignored by ecaccess).
- Returns:
ecaccess-job-listcommand.
- get_completed_job_names(job_names: list[str] | None = None) list[str]#
Retrieve the names of all files ending with ‘_COMPLETED’ from the remote log directory using SSH.
Uses
ecaccess-file-dirto inspect the remote directory and filters results locally. Ifjob_namesis provided, only those names are checked.- Parameters:
job_names – Optional job names to restrict the lookup.
- Returns:
Job names whose
_COMPLETEDmarker exists remotely.
- get_file(filename, must_exist=True, relative_path='', ignore_log=False, wrapper_failed=False)#
Copies a file from the current platform to experiment’s tmp folder
- Parameters:
filename – file name
must_exist – If True, raises an exception if file can not be copied
relative_path – path inside the tmp folder
ignore_log
wrapper_failed
- Returns:
True if file is copied successfully, false otherwise
- get_mkdir_cmd()#
Gets command to create directories on HPC
- Returns:
command to create directories on HPC
- get_remote_log_dir() Path#
Get the variable remote_log_dir that stores the directory of the experiment’s log.
- Returns:
The remote_log_dir variable.
- get_ssh_output()#
Gets output from last command executed.
- Returns:
output from last command
- get_submitted_job_id(output: str, x11: bool = False) list[str]#
Parses the output of the submit command to get the job ID.
- Parameters:
output – output of the submit command.
x11 – whether the job is an x11 job, which has a different output format.
- Returns:
job ID of the submitted job.
- get_submitted_jobs_by_name(script_names: list[str]) list[int]#
Return submitted ecaccess job IDs by script name.
This fallback is used when the batched submit command does not return one recoverable job identifier per submitted script.
- Parameters:
script_names – Submitted script filenames.
- Returns:
Matching ecaccess job IDs in submission order, one per script. Returns an empty list if any script name has no newly submitted job.
- move_file(src, dest, must_exist=False)#
Moves a file on the platform (includes .err and .out).
- Parameters:
src – source name
dest – destination name
must_exist – ignore if file exist or not
- parse_all_jobs_output(output, job_id)#
Parse ecaccess-job-list tabular output for a single job ID.
- Parameters:
output – Raw output from
get_check_all_jobs_cmd().job_id – ecaccess job ID to look up.
- Returns:
Job status word (e.g.
EXEC,DONE,STOP) or an empty string if the job is not found.
- read_jobid_from_remote_log(remote_path: str) int | None#
Read the JOBID from the first line of the remote output file.
Overrides
ParamikoPlatform.read_jobid_from_remote_logbecauseEcPlatform.send_commandruns commands locally, so a plainhead -1would not find the remote file.Downloads the file via
ecaccess-file-getand parses the JOBID from the[INFO] JOBID=marker on the first line.
- restore_connection(as_conf: AutosubmitConfig, log_recovery_process: bool = False) None#
Restores the SSH connection to the platform.
- Parameters:
as_conf – The Autosubmit configuration object used to establish the connection.
log_recovery_process – Indicates that the call is made from the log retrieval process.
- send_command(command, ignore_log=False, x11=False) bool#
Sends a given command to an HPC platform.
- Parameters:
command – The command to send to the HPC.
ignore_log – Whether logging is enabled or not for this function.
x11 – Whether X11 is enabled for the SSH session.
- Returns:
True if executed, False if failed
- send_file(filename, check=True) bool#
Sends a local file to the platform.
- Parameters:
filename – The name of the file to send.
check – Whether the platform must perform tests (e.g. for permission).
- set_start_time_from_remote_stat_file(job_list: list) None#
Set
start_time_timestampfrom line 1 (second line) of each remote STAT file.Reads line 1 (not line 0) because L0 is now submit_time.
- Parameters:
job_list – Jobs whose start times should be filled from remote STAT files.
- test_connection(as_conf: AutosubmitConfig) None#
Tests the connection using the provided configuration.
- Parameters:
as_conf – The configuration to use for testing the connection.
- update_cmds()#
Updates commands for platforms
- class autosubmit.platforms.pjmplatform.PJMPlatform(expid, name, config)#
Bases:
ParamikoPlatformClass to manage jobs to host using PJM scheduler
- Parameters:
expid (str) – experiment’s identifier
- cancel_jobs(job_ids: list[str]) None#
Cancel PJM jobs by their IDs.
- Parameters:
job_ids (list[str]) – List of PJM job IDs to cancel.
- Return type:
None
- check_remote_log_dir()#
Creates log dir on remote host
- get_check_all_jobs_cmd(jobs_id)#
Returns command to check jobs status on remote platforms.
- Parameters:
jobs_id – id of jobs to check
- Returns:
command to check job status
- get_job_id_by_job_name_cmd(job_name)#
Returns command to get job id by job name on remote platforms
- Parameters:
job_name
- Returns:
str
- get_mkdir_cmd()#
Gets command to create directories on HPC
- Returns:
command to create directories on HPC
- get_remote_log_dir()#
Get the variable remote_log_dir that stores the directory of the experiment’s log.
- Returns:
The remote_log_dir variable.
- get_submitted_job_id(output: str, x11: bool = False) list[int]#
Parse the output of the submit command and return PJM job IDs.
- Parameters:
output (str) – Output of the submit command.
x11 (bool) – Unused for PJM, kept for API compatibility.
- Returns:
Parsed PJM job IDs.
- Return type:
list[int]
- get_submitted_jobs_by_name(script_names: list[str]) list[int]#
Get submitted PJM job IDs by script name.
This is a fallback used when the submit command output does not contain enough information to recover all submitted job IDs directly.
- Parameters:
script_names (list[str]) – Submitted script filenames.
- Returns:
Matching PJM job IDs in the same order as
script_names.- Return type:
list[int]
- parse_job_list(job_list: list[Job]) str#
Convert a list of job_list to job_list_cmd.
- Parameters:
job_list (list) – list of jobs
- Returns:
job status
- Return type:
str
- submit_error(output)#
Check if the output of the submit command contains an error message.
- Parameters:
output – output of the submit cmd
- Returns:
boolean
- update_cmds()#
Update commands for platforms.
Slurm Platform.
This file contains code that interfaces between Autosubmit and a Slurm Platform.
- class autosubmit.platforms.slurmplatform.SlurmPlatform(expid: str, name: str, config: dict, auth_password: str | list[str] | None = None)#
Bases:
ParamikoPlatformClass to manage jobs to host using SLURM scheduler.
- static allocated_nodes() str#
It sets the allocated nodes of the wrapper
- Returns:
A command that changes the num of Node per job
- cancel_jobs(job_ids: list[str]) None#
Cancel jobs by their IDs.
- Parameters:
job_ids – List of job IDs to cancel.
- check_remote_log_dir() None#
Creates log dir on remote host.
- create_a_new_copy()#
Return a copy of a SlurmPlatform object with the same expid, name and config as the original.
- Returns:
A new platform type slurm
- get_check_all_jobs_cmd(jobs_id: str)#
Generates sacct command to all the jobs passed down.
- Parameters:
jobs_id – ID of one or more jobs.
- Returns:
sacct command to all jobs.
- static get_estimated_queue_time_cmd(job_id: str)#
Gets an estimated queue time to the job selected.
- Parameters:
job_id – ID of a job.
- Returns:
Gets estimated queue time.
- get_job_energy_cmd(job_id: str) str#
Generates a command to get data from a job JobId, State, NCPUS, NNodes, Submit, Start, End, ConsumedEnergy, MaxRSS, AveRSS%25.
- Parameters:
job_id – ID of a job.
- Returns:
Command to get job energy.
- get_job_id_by_job_name_cmd(job_name: str) str#
Looks for a job based on its name.
- Parameters:
job_name – Name given to a job
- Returns:
Command to look for a job in the queue.
- get_mkdir_cmd() str#
Get the variable mkdir_cmd that stores the mkdir command.
- Returns:
Mkdir command
- get_remote_log_dir() Path#
Get the variable remote_log_dir that stores the directory of the Log of the experiment.
- Returns:
The remote_log_dir variable.
- get_submitted_job_id(output: str, x11: bool = False) int | list[Any]#
Parses the output of the submit command to get the job ID.
- Parameters:
output – output of the submit command.
x11 – whether the job is an x11 job, which has a different output format.
- Returns:
job ID of the submitted job.
- get_submitted_jobs_by_name(script_names: list[str]) list[int]#
Return submitted Slurm job IDs by script name.
This fallback is used when the batched submit command does not return one recoverable job identifier per submitted script.
- Parameters:
script_names – Submitted script filenames.
- Returns:
Matching Slurm job IDs in submission order.
- parse_queue_reason(output: str, job_id: str) str#
Parses the queue reason from the output of the command.
- Parameters:
output – output of the command.
- Returns:
queue reason.
- update_cmds() None#
Updates commands for platforms.
- wrapper_header(**kwargs: Any) str#
It generates the header of the wrapper configuring it to execute the Experiment.
- Parameters:
kwargs – Key arguments associated to the Job/Experiment to configure the wrapper.
- Returns:
a sequence of slurm commands.
- class autosubmit.platforms.locplatform.LocalPlatform(expid: str, name: str, config: dict, auth_password: str | list[str] | None = None)#
Bases:
ParamikoPlatformClass to manage jobs to localhost.
- cancel_jobs(job_ids: list[str]) None#
Cancel local processes by their PIDs.
- Parameters:
job_ids – List of local process IDs to cancel.
- check_file_exists(src: str, wrapper_failed: bool = False, sleeptime: int = 1, max_retries: int = 1)#
Checks if a file exists in the platform.
- Parameters:
src – source name.
wrapper_failed – Checks inner jobs files. Defaults to False.
sleeptime – Time to sleep between retries. Defaults to 1.
max_retries – Maximum number of retries. Defaults to 1
- Returns:
True if the file exists, False otherwise.
- check_remote_permissions() bool#
Check remote permissions on a platform.
This is needed for Paramiko and PS and other platforms.
It uses the platform scratch project directory to create a subdirectory, and then removes it. It does it that way to verify that the user running Autosubmit has the minimum permissions required to run Autosubmit.
It does not check Slurm, queues, modules, software, etc., only the file system permissions required.
- Returns:
Trueon success,Falseotherwise.
- compress_file(file_path: str) None#
Compress a file.
- Parameters:
file_path – file path
- Returns:
The path to the compressed file. None if compression failed.
- connect(as_conf: AutosubmitConfig, reconnect: bool = False, log_recovery_process: bool = False) None#
Establishes an SSH connection to the host.
- Parameters:
as_conf – The Autosubmit configuration object.
reconnect – Indicates whether to attempt reconnection if the initial connection fails.
log_recovery_process – Specifies if the call is made from the log retrieval process.
- Returns:
None
- delete_file(filename, del_cmd=False)#
Deletes a file from this platform
- Parameters:
filename – file name
- Returns:
True if successful or file does not exist
- get_check_all_jobs_cmd(jobs_id: str) str#
Return a shell command that checks the status of all given process IDs.
For each PID, the command outputs a line
<pid> <status>where status is0if the process is running (non-zombie) and1otherwise.- Parameters:
jobs_id – Comma-separated list of process IDs to check.
- Returns:
Shell command outputting
<pid> <status>per line.
- get_file(filename: str, must_exist: bool = True, relative_path: str = '', ignore_log: bool = False, wrapper_failed: bool = False) bool#
Copies a file from the current platform to experiment’s tmp folder
- Parameters:
filename – file name
must_exist – If True, raises an exception if file can not be copied
relative_path – path inside the tmp folder
ignore_log
wrapper_failed
- Returns:
True if file is copied successfully, false otherwise
- get_logs_files(exp_id: str, remote_logs: tuple[str, str]) None#
Do nothing because the log files are already in the local platform (redundancy).
- get_mkdir_cmd()#
Gets command to create directories on HPC
- Returns:
command to create directories on HPC
- get_remote_log_dir() Path#
Get the variable remote_log_dir that stores the directory of the experiment’s log.
- Returns:
The remote_log_dir variable.
- get_ssh_output()#
Gets output from last command executed.
- Returns:
output from last command
- get_submitted_job_id(raw_output: str, x11: bool = False) list[str]#
Parses the output of the submit command to get the job ID.
- Parameters:
raw_output – output of the submit command.
x11 – whether the job is an x11 job, which has a different output format.
- Returns:
job ID of the submitted job.
- move_file(src: str, dest: str, must_exist: bool = False) bool#
Moves a file on the platform (includes .err and .out)
- Parameters:
src – source name.
dest – destination name.
must_exist – ignore if file exist or not.
- parse_all_jobs_output(output: str, job_id: int) str#
Parse process-status output for the given job ID.
- Parameters:
output – Output of
get_check_all_jobs_cmd().job_id – Process ID to look up.
- Returns:
'0'if running,'1'if not running or not found.
- read_file(src: str | Path, max_size: int | None = None) bytes | None#
Read file content as bytes. If max_size is set, only the first max_size bytes are read.
- Parameters:
src – file path
max_size – maximum size to read
- read_jobid_from_remote_log(remote_path: str) int | None#
Reads the JOBID from the first line of a remote log file.
- Parameters:
remote_path – full remote path to the log file
- Returns:
job ID if found, None otherwise
- remove_multiple_files(filenames: str) str#
Creates a shell script to remove multiple files in the remote and sets the appropriate permissions.
- Parameters:
filenames – A string containing the filenames to be removed.
- Returns:
An empty string.
- restore_connection(as_conf: AutosubmitConfig, log_recovery_process: bool = False) None#
Restores the SSH connection to the platform.
- Parameters:
as_conf (AutosubmitConfig) – The Autosubmit configuration object used to establish the connection.
log_recovery_process (bool) – Indicates that the call is made from the log retrieval process.
- send_command(command: str, ignore_log=False, x11=False) bool#
Sends a given command to an HPC platform.
- Parameters:
command – The command to send to the HPC.
ignore_log – Whether logging is enabled or not for this function.
x11 – Whether X11 is enabled for the SSH session.
- Returns:
True if executed, False if failed
- send_file(filename: str, check: bool = True) bool#
Sends a file to a specified location using a command.
- Parameters:
filename (str) – The name of the file to send.
check (bool) – Unused in this platform.
- Returns:
True if the file was sent successfully.
- Return type:
bool
- test_connection(as_conf: AutosubmitConfig) None#
Test if the connection is still alive, reconnect if not.
- Parameters:
as_conf – Autosubmit configuration.
- Returns:
Nonewhen the connection is healthy, otherwise a message describing the problem.
- update_cmds()#
Updates commands for platforms.
- write_jobid(jobid: str, complete_path: str) None#
Writes Job id in an out/err file.
- Parameters:
jobid – job id
complete_path – complete path to the file, includes filename