autosubmit.job#

class autosubmit.job.job.Job(name=None, job_id=None, status=None, priority=None, loaded_data=None)#

Class to handle all the tasks with Jobs at HPC.

A job is created by default with a name, a jobid, a status and a type. It can have children and parents. The inheritance reflects the dependency between jobs. If Job2 must wait until Job1 is completed then Job2 is a child of Job1. Inversely Job1 is a parent of Job2

add_children(children) → None#

Add children for the job. It also adds current job as a parent for all the new children

Parameters:

children – job’s children to add

add_parent(*parents) → None#

Add parents for the job. It also adds current job as a child for all the new parents

Parameters:

parents – job’s parents to add

apply_status(status: int) → None#

Apply a new status, resetting the per-attempt state when the job will run again.

Statuses in Status.RE_RUNNABLE (e.g. WAITING, READY) mean the job will be scheduled again, so attempt counters, stale scheduler id and log recovery state are reset to guarantee the new run starts clean (and its logs are recovered).

Parameters:

status – Numeric status value from Status.

assign_platform(submitter: ParamikoSubmitter, create: bool, new: bool) → None#

Assigns the platform to the job. :param submitter: Submitter object containing platform information. :param create: Flag indicating if the job is being created. :param new: Flag indicating if the job is new.

calendar_chunk(parameters)#

Calendar for chunks

Parameters:

parameters

Returns:

calendar_split(as_conf: AutosubmitConfig, parameters: dict, set_attributes: bool) → dict#

Calculate the calendar splits for the job.

This method processes the calendar splits based on the provided parameters and the Autosubmit configuration.

Parameters:
  • as_conf – The Autosubmit configuration object.

  • parameters – The dictionary containing job parameters.

  • set_attributes – Flag indicating whether to set attributes directly.

Returns:

The updated parameters dictionary containing calendar split information.

property can_retry: bool#

Whether the job is FAILED and has remaining retries.

check_completion(default_status=-1) → None#

Check whether a COMPLETED file exists on the platform.

This method sets self.new_status (the proposed status), not self.status (the committed status). The caller must later call update_status() to commit the change.

Parameters:

default_status – Status to propose when the COMPLETED file is absent. Defaults to Status.FAILED.

check_compressed_local_logs() → bool#

Checks if the current local log files are compressed versions (.gz or .xz) and updates the local_logs attribute accordingly.

check_end_time(attempt: int) → int#

Return end time (epoch seconds) from line 2 of the STAT file.

check_remote_log_exists(show_logs: bool = False) → bool#

Checks if remote log file exists on remote host

Parameters:

show_logs – Whether to show logs during the check

Returns:

True if remote log file exists, False otherwise

check_retrials_end_time() → list[int]#

Returns list of end datetime for retrials from total stats file

Returns:

date and time

check_retrials_start_time() → list[int]#

Returns list of start datetime for retrials from total stats file

Returns:

date and time

check_running_after(date_limit) → bool#

Checks if the job was running after the given date

Parameters:

date_limit – reference date

Returns:

True if job was running after the given date, false otherwise

check_script(as_conf: AutosubmitConfig, show_logs='false') → bool#

Checks if the script is well-formed.

Parameters:
  • as_conf – Autosubmit configuration.

  • show_logs – Whether to display logs or not.

Returns:

Returns True if the script is well-formed, otherwise returns False.

check_start_time(attempt: int) → int#

Return start time (epoch seconds) from line 1 of the STAT file.

check_started_after(date_limit) → bool#

Checks if the job started after the given date

Parameters:

date_limit – reference date

Returns:

True if job started after the given date, false otherwise

check_submit_time(attempt: int) → int#

Return submit time (epoch seconds) from line 0 of the STAT file.

property checkpoint#

Generates a checkpoint step for this job based on job.type.

property children: set#

Returns a list containing all children of the job

Returns:

child jobs

property children_names_str#

Comma separated list of children’s names

property chunk#

Current chunk.

property chunk_size#

Chunk size used to compute CPMIP metrics.

property chunk_size_unit#

Chunk size unit used to compute CPMIP metrics.

clean_attributes()#

Reset ephemeral job attributes, keeping only persistent state.

Returns:

None if the job is a terminal failure, otherwise None after resetting.

construct_real_additional_file_name(file_name: str) → str#

Constructs the real name of the file to be sent to the platform.

Parameters:

file_name – The name of the file to be sent.

Returns:

The full path of the file to be sent.

property cpmip_thresholds#

Thresholds for CPMIP metrics.

create_script(as_conf: AutosubmitConfig) → str#

Create the script file to be run for the job.

Parameters:

as_conf – Configuration object.

Returns:

Script’s filename.

property custom_directives#

List of custom directives.

property delay#

Current delay.

property delay_retrials#

TODO

delete_parent(parent) → None#

Remove a parent from the job

Parameters:

parent – parent to remove

property dependencies#

Current job dependencies.

edgeless() → bool#

Returns true if job has is edgless, else return false

Returns:

true if job has is edgless, otherwise return false

property export#

TODO.

property fail_count#

Number of failed attempts to run this job.

fix_local_logs_timestamps(current_timestamp: str, new_timestamp: str) → None#

Renames local log files to update the timestamp in their names without changing the prefix and extension.

It assumes that self.local_logs contains the new timestamp in their names.

Parameters:
  • current_timestamp – The current timestamp in the log file names.

  • new_timestamp – The new timestamp to replace the current one.

property frequency#

TODO.

get_checkpoint_files()#

Check if there is a file on the remote host that contains the checkpoint

get_last_retrials() → list[list[datetime]]#

Returns the retrials of a job, including the last COMPLETED run.

The selection stops, and does not include when the previous COMPLETED job is located or the list of registers is exhausted.

Returns:

list of dates of retrial [submit, start, finish] in datetime format

get_metric_folder(as_conf: AutosubmitConfig) → str#

Returns the default metric folder for the job.

Returns:

The metric folder path.

get_new_remotelog_name(attempt: int)#

Checks if remote log file exists on remote host if it exists, remote_log variable is updated :param

has_children() → bool#

Returns true if job has any children, else return false

Returns:

true if job has any children, otherwise return false

has_parents() → bool#

Returns true if job has any parents, else return false

Returns:

true if job has any parent, otherwise return false

property has_pending_logs: bool#

Whether there are still logs pending recovery.

has_valid_submit_time() → bool#

Whether the submit time can be used for log recovery.

Returns:

True if submit_time_timestamp is set and parses as YYYYMMDDHHMMSS.

property hyperthreading#

Detects if hyperthreading is enabled or not.

inc_fail_count()#

Increments fail count

init_platform(as_conf: AutosubmitConfig) → None#

Initialize the job’s platform.

The submitter comes from the job_list.submitter during an autosubmit run/inspect, but if not, it is created here.

Parameters:

as_conf – Autosubmit configuration.

init_runtime_parameters(as_conf: AutosubmitConfig, reset_logs: bool, called_from_log_recovery: bool) → None#

Initialize runtime parameters for the job.

Sets default values for job execution parameters including tasks, nodes, threads, processors, memory, reservations, and checkpoint steps. Optionally resets log-related attributes if requested.

Parameters:
  • as_conf – Autosubmit configuration object containing job settings.

  • reset_logs – Whether to reset log-related attributes.

  • called_from_log_recovery – Whether this initialization is called during log recovery.

static internal_slot_name(slot) → str#

Normalize the slot name to match the expected format.

This is useful for ensuring that the slot names are consistent when loading the job state from the DB which doesn’t have the “_” prefix.

static is_a_completed_retrial(fields: list) → bool#

Returns true only if there are 4 fields: submit start finish status, and status equals COMPLETED.

is_ancestor(job)#

Check if the given job is an ancestor :param job: job to be checked if is an ancestor :return: True if job is an ancestor, false otherwise :rtype bool

is_over_wallclock(effective_wallclock=None) → bool#

Check if the job is over the wallclock time, it is an alternative method to avoid platform issues.

is_parent(job)#

Check if the given job is a parent

Parameters:

job – job to be checked if is a parent

Returns:

True if job is a parent, false otherwise

log_recovery_call_count#

Number of log recovery calls made for this job, persisted by save_jobs and capped against fail_count.

property long_name: str#

Job’s long name. If not set, returns name

Returns:

long name

property member#

Current member.

property memory#

Memory requested for the job.

property memory_per_task#

Memory requested per task.

property name#

Current job full name.

property nodes#

Number of nodes that the job will use.

property notify_on#

Send mail notification on job status change.

property packed#

TODO

property parents: set#

Returns parent jobs list

Returns:

parent jobs

parse_time(wallclock) → timedelta | None#

Convert a HH:MM[:SS] wallclock to a datetime.timedelta.

Parameters:

wallclock – Wallclock to convert, e.g. '07:30' or '07:30:00'.

Returns:

The wallclock as a timedelta, or None if it cannot be parsed. '00:00' yields a zero-duration timedelta (not None). Non-string values return a one-day timedelta as a test workaround.

property partition: Platform | str#

Returns the queue to be used by the job. Chooses between serial and parallel platforms

:return HPCPlatform object for the job to use

property platform: Platform#

Returns the platform to be used by the job. Chooses between serial and parallel platforms

Returns:

HPCPlatform object for the job to use

process_scheduler_parameters(job_platform: Platform, chunk: int) → None#

Parsers YAML data stored in the dictionary and calculates the components of the heterogeneous job if any.

property processors#

Number of processors that the job will use.

property processors_per_node#

Number of processors per node that the job can use.

property queue: Platform | str#

Returns the queue to be used by the job. Chooses between serial and parallel platforms.

:return HPCPlatform object for the job to use

read_header_tailer_script(script_path: str, as_conf: AutosubmitConfig, is_header: bool)#

Opens and reads a script. If it is not a BASH script it will fail :(

Will strip away the line with the hash bang (#!)

Parameters:
  • script_path – relative to the experiment directory path to the script

  • as_conf – Autosubmit configuration file

  • is_header – boolean indicating if it is header extended script

recover_last_ready_date() → None#

Recovers the last ready date for this job

recover_log(as_conf: AutosubmitConfig) → None#

Recover log files and submit time for this job.

log_recovery_call_count caps how many recovery attempts are made for this job. It is persisted so the cap survives Autosubmit restarts.

Parameters:

as_conf – Experiment configuration.

reset_logs() → None#

Reset job log counters.

property retrials#

Max amount of retrials to run this job.

property scratch_free_space#

Percentage of free space required on the scratch.

property script#

Allows to launch inline code instead of using the file parameter

property sdate#

Current start date.

property section#

Type of the job, as given on job configuration file.

send_cpmip_notification(as_conf) → None#

Capture CPMIP metrics for job and send them as a notification.

Called before job attributes are cleared upon termination. If capture fails (returns None) the notification is silently skipped. If the notification itself fails the error is logged but not re-raised.

Parameters:

as_conf – experiment_configuration

set_ready_date() → None#

Sets the ready start date for the job

property shape: Platform#

Returns the shape of the job. Chooses between serial and parallel platforms

:return HPCPlatform object for the job to use

property split#

Current split.

property splits#

Max number of splits.

stat_file#

Number of failed attempts to run this job. (FAIL_COUNT)

stat_file_is_completed(attempt: int) → bool#

Check if FAILED/COMPLETED exists

stat_registered(attempt: int) → bool#

Check if the stats are already registered in the historical DB for this job and attempt.

The lookup uses the job name (unique per job and chunk) instead of the scheduler job id, which is not guaranteed to be unique, and restricts the search to the current run so a rerun does not match the previous run’s rows.

Parameters:

attempt – The fail_count (attempt) to look up.

Returns:

True if a historical record exists for this job and attempt in the current run.

property status_str#

String representation of the current status

property synchronize#

TODO.

property tasks#

Number of tasks that the job will use.

property threads#

Number of threads that the job will use.

property total_processors#

Number of processors requested by job. Reduces ‘:’ separated format if necessary.

update_check_variables(as_conf: AutosubmitConfig) → None#

Update job check variables from Autosubmit configuration. :param as_conf: The Autosubmit configuration object.

update_content(as_conf: AutosubmitConfig, parameters: dict) → tuple[str, list[str]]#

Create the script content to be run for the job.

Parameters:
  • as_conf – Autosubmit configuration.

  • parameters – Parameters dictionary.

Returns:

A tuple with the job script template and a list with the additional file names.

update_current_parameters(as_conf: AutosubmitConfig, parameters: dict) → dict#

Populate and update CURRENT_XXX parameters and placeholders in the given parameters dictionary.

Parameters:
  • as_conf – Autosubmit configuration object containing platforms_data, jobs_data and other experiment-level settings.

  • parameters – Parameters dictionary to be updated. This dict is modified

Returns:

The same parameters dictionary updated.

update_job_parameters(as_conf: Any, parameters: dict[str, Any], set_attributes: bool) → dict[str, Any]#

Update job parameters and optionally set job attributes.

Parameters:
  • as_conf – Autosubmit configuration object.

  • parameters – Dictionary of parameters to update.

  • set_attributes – Whether to set job attributes from parameters.

Returns:

Updated parameters dictionary.

update_job_variables_final_values(parameters: dict) → None#

Jobs variables final values based on parameters dict instead of as_conf This function is called to handle %CURRENT_% placeholders as they are filled up dynamically for each job

update_local_logs(attempt: int = 0) → None#

Updates the local log filenames based on the fail count.

Parameters:

attempt – The current attempt number.

update_parameters(as_conf: AutosubmitConfig, set_attributes: bool = False, reset_logs: bool = False) → dict#

Refresh the job’s parameters value.

This method reloads the Autosubmit configuration and updates the job’s parameters based on the configuration and the current state of the job.

Parameters:
  • as_conf – The Autosubmit configuration object.

  • set_attributes – Flag indicating whether to set attributes, defaults to False.

  • reset_logs – Flag indicating whether to reset logs, defaults to False.

static update_placeholders(as_conf: AutosubmitConfig, parameters: dict, replace_by_empty=False) → dict#

Find and substitute dynamic placeholders in parameters using the provided Autosubmit configuration helpers.

Parameters:
  • as_conf – Autosubmit configuration object.

  • parameters – Parameters dictionary potentially containing placeholders.

  • replace_by_empty – Flag indicating whether to replace dynamic variables with empty strings.

Returns:

Parameters with placeholders substituted.

update_start_time(attempt=-1)#

Updates the job’s start time based on the count of retries.

Parameters:

attempt – The retry count.

update_status(as_conf: AutosubmitConfig) → Status#

Updates job status, checking COMPLETED file if needed.

Parameters:

as_conf – Autosubmit configuration.

Returns:

The new status.

property validate_template#

Whether to print validate information about the job.

property wallclock#

Duration for which nodes used by job will remain allocated.

write_end_time(completed, attempt) → None#

Writes end timestamp to the TOTAL_STATS file and the experiment history database.

Parameters:
  • completed – True if the job has been completed, False otherwise

  • attempt – number of retrials

write_start_time(attempt: int) → bool#

Writes start date and time to TOTAL_STATS file and the history database.

Parameters:

attempt – The fail count to identify the correct database row.

Returns:

True if successful, False otherwise

write_stats(attempt: int) → bool#

Fetch the STAT file and write submit, start, end times and status.

The STAT file is expected to have four lines: submit_time, start_time, end_time, status.

Parameters:

attempt – The retrial count.

Returns:

True if the STAT file was fetched and written successfully.

write_submit_time(attempt: int) → None#

Writes submit date and time to the TOTAL_STATS file.

property x11#

Whether to use X11 forwarding

property x11_options#

Allows to set salloc parameters for x11

class autosubmit.job.job.RecoveryAttempt(attempt: int, success: bool, local_logs: tuple[str, str], remote_logs: tuple[str, str], error: str | None = None)#

Result of recovering logs for a single attempt.

class autosubmit.job.job.RecoveryReport(job_name: str, attempts: list[RecoveryAttempt] = <factory>, final_updated_log: int = 0, final_updated_stats: int = 0, all_succeeded: bool = False)#

Structured report of log recovery across all pending attempts.

class autosubmit.job.job.WrapperJob(name: str, job_id: int, status: str, priority: int, job_list: list[Job], total_wallclock: str, num_processors: int, platform: ParamikoPlatform, as_config: AutosubmitConfig, hold: bool = False, sections=None, method=None, wr_type=None)#

Defines a wrapper from a package.

Calls Job constructor.

Parameters:
  • name – Name of the Package

  • job_id – ID of the first Job of the package

  • status – ‘READY’ when coming from submit_ready_jobs()

  • priority – 0 when coming from submit_ready_jobs()

  • job_list – List of jobs in the package

  • total_wallclock – Wallclock of the package

  • platform – Platform object defined for the package

  • as_config – Autosubmit basic configuration object

  • hold – Whether the wrapper job is held on submission.

check_and_update_status(as_conf: AutosubmitConfig) → bool#

Check the status of the wrapper job and its inner jobs.

Parameters:

as_conf – Autosubmit configuration object.

Returns:

True if the status of the wrapper job has changed, otherwise False.

log_recovery_call_count#

Number of log recovery calls made for this job, persisted by save_jobs and capped against fail_count.

stat_file#

Number of failed attempts to run this job. (FAIL_COUNT)

class autosubmit.job.job_common.Status#

Class to handle the status of a job

class autosubmit.job.job_common.Type#

Class to handle the status of a job

autosubmit.job.job_common.get_job_status(status: str) → int | None#

Convert job status from text to integer code.

Parameters:

status – Status text.

Returns:

The integer status value.

autosubmit.job.job_common.increase_wallclock_by_chunk(current: str, increase: str, chunk: int) → str#

Receives the wallclock times an increases it according to a quantity times the number of the current chunk. The result cannot be larger than the platform max_wallclock. If Chunk = 0 then no increment.

Parameters:
  • current – WALLCLOCK HH:MM

  • increase – WCHUNKINC HH:MM

  • chunk – chunk number

Returns:

HH:MM wallclock

autosubmit.job.job_common.max_wallclock_seconds(wallclocks: Iterable[str], platform_max_wallclock: str | None = None, fallback: int = 0) → int#

Return the longest wallclock (seconds) among the given ones.

Entries without a wallclock (empty, unparseable or '00:00') fall back to the platform maximum wallclock. If no wallclock is available at all, fallback is returned.

Parameters:
  • wallclocks – Wallclocks to evaluate.

  • platform_max_wallclock – Platform maximum wallclock to use as fallback.

  • fallback – Value returned when no wallclock is available.

Returns:

The longest wallclock in seconds.

autosubmit.job.job_common.parse_output_number(string_number: str) → float#

Parses number in format 1.0K 1.0M 1.0G

Parameters:

string_number – String representation of number

Returns:

convertion to float format

autosubmit.job.job_common.separate_section_entries(filter_entries: str) → list[str]#

Separate section entries with optional splits separated by comma into a list.

Parameters:

filter_entries – string with the entries separated by comma

Returns:

list of entries

autosubmit.job.job_common.wallclock_to_seconds(wallclock: str | None) → int | None#

Convert a HH:MM[:SS] wallclock to seconds.

Parameters:

wallclock – Wallclock to convert, e.g. '07:30' or '07:30:00'.

Returns:

The wallclock in seconds, or None if it is empty, not a string or cannot be parsed.

class autosubmit.job.job_list.JobList(expid, config, parser_factory, run_mode=False, disable_save=False, submitter=None)#

Class to manage the list of jobs to be run by autosubmit

add_special_conditions(job: Job, special_conditions: dict[str, Any], parent: Job) → None#

Add special conditions to the edge between a parent job and a child job in the workflow graph.

Parameters:
  • job – The child job to which special conditions are applied.

  • special_conditions – Dictionary containing special condition parameters (e.g., STATUS, FROM_STEP, FAIL_OK).

  • parent – The parent job from which the edge originates.

assign_unique_fake_id(package: Any, max_retries: int = 2) → None#

Assign a unique fake ID to all jobs in the package, ensuring no collision with existing IDs.

This is for the -CW flag, as the wrapper won’t be really submitted.

the wrappers.id db field has a non-nullable flag

Parameters:
  • package – The job package containing jobs to assign the ID.

  • max_retries – Maximum number of attempts to generate a unique ID.

Raises:

RuntimeError – If a unique ID cannot be generated after max_retries.

build_sections_data_to_store() → list[dict[str, Any]]#

Build a list of dictionaries representing section data for database storage.

Returns:

List of dictionaries, each representing a section’s data.

static check_checkpoint(job, parent)#

Check if a checkpoint step exists for this edge

check_scripts(as_conf: AutosubmitConfig) → bool#

When we have created the scripts, all parameters should have been substituted. %PARAMETER% handlers are not allowed.

Parameters:

as_conf – experiment configuration

check_special_status() → list[Job]#

Check if all parents of a job have the correct status for checkpointing.

Returns:

List of jobs that fulfill the special conditions for checkpointing.

clear() → None#

Clears the entire workflow graph.

clear_wrappers_db(preview=True) → None#

Clears all wrapper jobs from the database. :param preview: If True, the action will be executed in the wrapper simulation table.

compute_section_differences() → dict[str, dict[str, Any]]#

Compute the differences between the current sections and the persistent sections in the database.

Returns:

A dictionary mapping section names to their change type and details: ‘removed’, ‘modified’, or ‘added’.

continue_run() → bool#

Loads the next possible jobs and edges from the database.

Returns:

True if there are active jobs to run, False otherwise.

ensure_parents_loaded(job: Job) → None#

Load parent Job objects for a job from the database if not already set.

Creates lightweight Job objects for parents without adding them to the graph. No-op if the job already has parents or no dbmanager is available.

Parameters:

job – The job whose parents need to be loaded.

property expid#

Returns the experiment identifier

Returns:

experiment’s identifier

fill_parents_children()#

Fill the job._parents and job._children attributes

find_and_delete_redundant_relations(problematic_jobs: dict) → None#

Jobs with intrinsic rules than can’t be safely not added without messing other workflows. The graph will have the least amount of edges added as much as safely possible before this function. Structure: problematic_jobs structure is {section: {child_name: [parent_names]}}

Returns:

generate(as_conf: AutosubmitConfig, date_list: list[str], member_list: list[str], num_chunks: int, chunk_ini: int, parameters: dict[str, Any], date_format: str, default_retrials: int, default_job_type: str, new: bool = True, show_log: bool = True, force: bool = False, full_load: bool = False, check_failed_jobs: bool = False, monitor: bool = False) → None#

Generates the workflow graph based on the provided configuration and parameters. :param as_conf: Autosubmit configuration object. :param date_list: List of dates for job generation. :param member_list: List of members for job generation. :param num_chunks: Number of chunks for job generation. :param chunk_ini: Initial chunk index for job generation. :param parameters: Dictionary of parameters for job generation. :param date_format: Date format string. :param default_retrials: Default number of retrials for jobs. :param default_job_type: Default job type for jobs. :param new: If True, initializes new jobs. :param show_log: If True, shows log messages during generation. :param force: If True, forces regeneration of the workflow graph. :param full_load: If True, loads the full graph from the database. :param check_failed_jobs: If True, checks for failed jobs during loading. :param monitor: If True, the edges won’t be removed even if there are differences in sections.

get_active(platform=None, wrapper=False)#

Returns a list of active jobs (In platforms queue + Ready).

Parameters:
  • wrapper

  • platform – job platform

Returns:

active jobs

get_all(wrapper=False) → list#

Returns a list of all jobs.

Parameters:
  • wrapper

  • platform – job platform

Returns:

all jobs

get_children_edges(job_name: str) → dict#

Get the children of a job in the graph

Parameters:

job_name – name of the job to check

Returns:

list of children

get_chunk_list()#

Get inner chunk list.

Returns:

chunk list

get_completed(platform=None, wrapper=False) → list#

Returns a list of completed jobs

Parameters:
  • wrapper

  • platform – job platform

Returns:

completed jobs

get_date_list() → list#

Get inner date list.

Returns:

date list

get_delayed(platform=None) → list#

Returns a list of delayed jobs.

Parameters:

platform – job platform

Returns:

delayed jobs

get_failed(platform=None, wrapper=False) → list#

Returns a list of failed jobs.

Parameters:
  • wrapper

  • platform – job platform

Returns:

failed jobs

get_filters_to_apply(job: Job, dependency: Dependency) → dict#

Get the filters to apply for a given job and dependency. :param job: The job object containing job details. :param dependency: The dependency object containing dependency details. :return: A dictionary of filters to apply for the job based on the dependency relationships.

get_held_jobs(platform=None) → list[Job]#

Returns a list of jobs in the platforms (Held).

Parameters:

platform – job platform

Returns:

jobs in platforms

get_in_queue(platform=None, wrapper=False) → list#

Returns a list of jobs in the platforms (Submitted, Running, Queuing, Unknown,Held).

Parameters:
  • wrapper

  • platform – job platform

Returns:

jobs in platforms

get_job_by_name(name: str) → Job | None#

Returns the job that its name matches parameter name.

Parameters:

name – name to look for

Returns:

found job

get_job_list() → list#

Get inner job list.

Returns:

job list

Parameters:
  • select_jobs_by_name – job name

  • select_all_jobs_by_section – section name

  • filter_jobs_by_section – section, date , member? , chunk?

Returns:

jobs_list names

get_jobs_by_section(section_list: list, banned_jobs: list | None = None, get_only_non_completed: bool = False) → list#

Get jobs by section.

This method filters jobs based on the provided section list and banned jobs list. It can also filter out completed jobs if specified.

Parameters: section_list (list): List of sections to filter jobs by. banned_jobs (list, optional): List of jobs names to exclude from the result. Defaults to an empty list. get_only_non_completed (bool, optional): If True, only non-completed jobs are included. Defaults to False.

Returns: list: List of jobs that match the criteria.

get_jobs_by_section_db(section_list: list, banned_jobs: list | None = None, get_only_non_completed: bool = False, status_filter: str | None = None) → set[str]#

Get job names by section from the database.

Mirrors get_jobs_by_section() but queries the database directly instead of iterating the in-memory job list.

Parameters:
  • section_list – List of sections to filter jobs by.

  • banned_jobs – List of job names to exclude from the result. Defaults to an empty list.

  • get_only_non_completed – If True, only non-completed jobs are included. Defaults to False.

  • status_filter – If set, only jobs with this status are included.

Returns:

Set of job names matching the criteria.

get_member_list() → list#

Get inner member list.

Returns:

member list

get_ordered_jobs_by_date_member(wrapper_name: str) → None | dict#

Get the dictionary of jobs ordered according to wrapper’s expression divided by date and member.

Parameters:

wrapper_name – name of the wrapper

Returns:

dictionary of jobs ordered by date and member

get_parents_edges(job_name: str) → dict#

Get the parents of a job in the graph

Parameters:

job_name – name of the job to check

Returns:

list of parents

get_prepared(platform=None) → list#

Returns a list of prepared jobs.

Parameters:

platform – job platform

Returns:

prepared jobs

get_queuing(platform=None, wrapper=False) → list#

Returns a list of jobs queuing.

Parameters:
  • wrapper

  • platform – job platform

Returns:

queuedjobs

get_ready(platform=None, hold=False, wrapper=False) → list#

Returns a list of ready jobs.

Parameters:
  • wrapper

  • hold

  • platform – job platform

Returns:

ready jobs

get_running(platform=None, wrapper=False) → list#

Returns a list of jobs running.

Parameters:
  • wrapper

  • platform – job platform

Returns:

running jobs

get_status_counts() → dict[str, int]#

Return status counts of ALL jobs from the database.

The counts are computed from the persisted jobs table, which keeps every job (including finished jobs unloaded from memory), so they are complete. Keys follow the same convention as ExperimentHistory.get_status_counts_from_job_list.

get_submitted(platform=None, hold=False, wrapper=False) → list#

Returns a list of submitted jobs.

Parameters:
  • wrapper

  • hold

  • platform – job platform

Returns:

submitted jobs

get_uncompleted(platform=None, wrapper=False) → list#

Returns a list of completed jobs.

Parameters:
  • wrapper

  • platform – job platform

Returns:

completed jobs

get_unknown(platform=None, wrapper=False) → list#

Returns a list of jobs on unknown state.

Parameters:
  • wrapper

  • platform – job platform

Returns:

unknown state jobs

get_unsubmitted(platform=None, wrapper=False) → list#

Returns a list of unsubmitted jobs.

Parameters:
  • wrapper

  • platform – job platform

Returns:

all jobs

get_waiting(platform=None, wrapper=False) → list#

Returns a list of jobs waiting.

Parameters:
  • wrapper

  • platform – job platform

Returns:

waiting jobs

get_waiting_remote_dependencies(platform_type='slurm') → list#

Returns a list of jobs waiting on slurm scheduler.

Parameters:

platform_type – platform type

Returns:

waiting jobs

get_wrappers_id_from_db() → list[int]#

Get a list of all wrapper job IDs from the database.

Returns:

List of wrapper job IDs.

property graph_dict: list[dict[str, Any]]#

Converts the graph edges into a dictionary structure matching the ExperimentStructureTable.

Returns:

A list of dictionaries representing the edges.

property graph_dict_by_job_name#

Converts the graph edges into a dictionary structure matching the ExperimentStructureTable. :return: A list of dictionaries representing the edges.

has_children(job_name: str) → bool#

Check if a job has children in the graph

Parameters:

job_name – name of the job to check

Returns:

True if the job has children, False otherwise

has_parents(job_name: str) → bool#

Check if a job has parents in the graph

Parameters:

job_name – name of the job to check

Returns:

True if the job has parents, False otherwise

is_wrapper_still_running(job: Job) → bool#

Check if the wrapper job for a given job is still running.

Parameters:

job – The job to check.

Returns:

True if the wrapper job is still running, False otherwise.

property job_list: list[Job]#

Dynamically return a list of all ‘job’ attributes from the graph nodes.

load_edges(job_list, full_load=False) → list[dict[str, Any]]#

Loads the job edges

load_job_by_name(job_name: str) → Job | None#

Loads a job by its name from the database.

Parameters:

job_name – Name of the job to load.

Returns:

The loaded job object or None if not found.

load_jobs(full_load: bool = False, load_failed_jobs: bool = False) → list[Job]#

Load jobs from the database.

Load job nodes from persistent storage into memory and return them as a list of Job instances.

Parameters:
  • full_load – If True, load all jobs and edges; otherwise load only the subset necessary for continued execution.

  • load_failed_jobs – If True, include jobs in failed states when loading.

Returns:

A list of loaded Job objects.

Raises:

Exception – If a database access error occurs while loading jobs.

load_sections() → list[dict[str, Any]]#

Loads the sections from the database.

Returns:

List of sections.

load_wrappable_jobs_by_section(section: str, loaded_tracker: set[str]) → None#

Load non-completed jobs from a section whose cross-section parents are all COMPLETED.

Skips jobs already in memory or tracked. Tracks newly loaded names in loaded_tracker for later cleanup.

Parameters:
  • section – Section name to load jobs from.

  • loaded_tracker – Set to which newly loaded job names are added.

load_wrappers(preview: bool = False) → None#

Load wrapper jobs and their inner jobs from the database, and populate the job package map. Only wrappers matching the current run_id are loaded.

Parameters:

preview – If True, load wrappers in preview mode.

property parameters: dict#

List of parameters common to all jobs

Returns:

parameters

print_with_status(status_change: dict[Any, Any] | None = None, nocolor=False, existing_list=None) → str#

Returns the string representation of the dependency tree of the Job List

Parameters:
  • status_change – List of changes in the list, supplied in set status

  • nocolor – True if the result should not include color codes

  • existing_list – External List of Jobs that will be printed, this excludes the inner list of jobs.

Returns:

String representation of the Job List

process_wrapper_jobs(wrapper_section: str, inner_sections: list[str]) → None#

Processes wrapper jobs by loading inner jobs and creating a sorted dictionary of jobs. :param wrapper_section: The section name of the wrapper job. :param inner_sections: List of inner section names to load jobs from.

recover_all_completed_jobs_from_exp_history(platform: Platform = None) → set[str]#

Recover all completed jobs from experiment history

Parameters:

platform – Platform to filter by.

Returns:

Set of completed job names.

recover_last_data(finished_jobs: list[Job] | None = None) → None#

Recover job IDs, log names and submit time for finished jobs from experiment history.

Jobs whose id/updated_log/submit_time are still meaningful are left untouched so the main loop can recover their logs. Otherwise the last known data is restored from the database (when available) and the job is marked as fully recovered so the main loop skips it.

Parameters:

finished_jobs – Optional list of finished Job objects to recover data for.

recover_logs(from_db: bool = False) → bool#

Update jobs’ log recovered status. Loads finished jobs from DB that need recovery.

remove_outdated_information_from_database(differences: dict[str, Any]) → None#

Removes outdated information from the database based on the differences found in sections.

Parameters:

differences – Dictionary containing the differences in sections.

remove_rerun_only_jobs() → None#

Removes all jobs to be run only in reruns.

rerun(job_list_unparsed, as_conf, monitor=False) → None#

Updates job list to rerun the jobs specified by a job list.

Parameters:
  • job_list_unparsed – list of jobs to rerun

  • as_conf – experiment configuration

  • monitor – if True, the job list will be monitored

reset_updated_logs() → None#

Reset updated_log and updated_stats to 0 for all jobs with fail_count == 0.

retrieve_symbols() → dict#

Retrieves dictionaries that map the collection of packages in the experiment to symbols for plotting. (Used by the autosubmit stats command).

Returns:

Dictionary mapping package names to symbols.

static retrieve_times(status_code, name, tmp_path, make_exception=False, job_times=None, seconds=False, job_data_collection: JobData | None = None) → None | JobRow#

Retrieve job timestamps from database.

Parameters:
  • status_code – Code of the Status of the job

  • name – Name of the job

  • tmp_path – Path to the tmp folder of the experiment

  • make_exception – flag for testing purposes

  • job_times – Detail from as_times.job_times for the experiment

  • seconds – seconds

  • job_data_collection – Collection of Jobs

Returns:

minutes the job has been queuing, minutes the job has been running, and the text that represents it

save_edges()#

Persists the job edges

save_jobs(jobs_to_save: list[Job] | None = None, reset_log_counters: bool = False) → None#

Persists the job list

Parameters:
  • jobs_to_save – Optional list of jobs to save. If None, saves all jobs in the job list.

  • reset_log_counters – If True, resets the log counters for the jobs being saved. Defaults to False.

Raises:

Exception – If a database access error occurs while saving jobs.

save_sections() → None#

Saves the sections of the job list to the database.

save_wrappers(scripts: Any, as_conf: Any, preview: bool = False) → None#

Save wrapper jobs for job packages that are not in the failed set. Each wrapper is tagged with the current run_id for run-level isolation.

Parameters:
  • scripts – List of job package objects to process.

  • as_conf – Autosubmit configuration object.

  • preview – Whether to run in preview mode.

sort_by_id() → list#

Returns a list of jobs sorted by id.

Returns:

jobs sorted by ID

sort_by_name() → list#

Returns a list of jobs sorted by name.

Returns:

jobs sorted by name

sort_by_status() → list#

Returns a list of jobs sorted by status.

Returns:

job sorted by status

sort_by_type() → list#

Returns a list of jobs sorted by type.

Returns:

job sorted by type

split_by_platform()#

Splits the job list by platform name

Returns:

job list per platform

unload_finished_jobs()#

Unloads finished jobs and edges from the memory.

update_db_wrappers()#

Update the wrapper jobs in the database with the current status of the wrapper jobs in memory.

update_from_file(store_change: bool = True) → bool#

Update job statuses from an external updated_list_<EXPID>.txt file.

Active jobs (QUEUING/RUNNING/SUBMITTED) are cancelled on their platform before any status change (when the platform is reachable), and active statuses cannot be set as a target. Lines whose target status equals the job’s current one are ignored, and when a job appears more than once the last line wins. Job names and statuses are matched case-insensitively; malformed lines are skipped with a warning.

Jobs that are not currently loaded in memory (e.g. they finished in a previous run or iteration) are resolved against the database. The change is applied to their stored row directly, without loading the job into the graph; it will be picked up on the next iteration when the job is reloaded.

Parameters:

store_change – If True, rename the update file after processing to prevent reloading.

Returns:

True if an update file was found (and attempted to process), False otherwise.

update_genealogy()#

When we have created the job list, every type of job is created. Update genealogy remove jobs that have no templates

update_list(as_conf: AutosubmitConfig, store_change: bool = True, from_set_status: bool = False) → bool#
Updates job list, resetting failed jobs and changing to READY

all WAITING jobs with all parents COMPLETED

Parameters:
  • as_conf – Autosubmit configuration object.

  • store_change – Whether to store changes after update.

  • from_set_status – If called from set status.

Returns:

True if any job status was updated, False otherwise.

update_wrappers_references() → None#

Updates the job references after a graph recreation to point to the actual Job objects and remove completed wrappers

autosubmit.job.job_list.load_job_list(expid, as_conf, monitor=False, new=True, full_load=True, submitter=None, check_failed_jobs=False, run_mode=False, run_members: list[str] | None = None) → JobList#

Load the JobList for a given experiment.

Parameters:
  • expid – experiment id

  • as_conf – autosubmit configuration

  • monitor – whether to monitor the experiment or not

  • new – whether to create a new job list or not

  • full_load – whether to load all job data or not

  • submitter – submitter to be used

  • check_failed_jobs – whether to check failed jobs or not

  • run_mode – whether to load the job list in run mode or not

  • run_members – optional list of members to restrict the run to. Set before loading the job graph so that only the allowed members are loaded into memory and therefore submitted.

Returns:

JobList object