seibuilder.run package

Module for run external codes (e.g. packmol).

check_job_status(job_id: int, job_out_file: str, job_err_file: str, slurm: bool = True, verbose: int = 0) Tuple[str, datetime | None][source]

Check job status.

Parameters:
  • job_id (int) – the command PID (equivalent to job ID).

  • job_out_file (str) – the path where the job STDOUT is stored.

  • job_err_file (str) – the path where the job STDERR is stored.

  • slurm (bool, optional) – [NotImplemented] if True will write a SLURM script. Defaults to False.

  • verbose (int, optional) – loudness controller: - 0: print errors - 1: print errors and warnings - 2: print errors, warnings and info - 3: print errors, warnings, info and debugger messages. Defaults to 0.

Raises:

NotImplementedError – raise the error if you try to use it with SLURM Workload Manager.

Returns:

tuple containing:
  • str: job status.

  • datetime: the ending time if completed, None otherwise

Return type:

Tuple[str, datetime | None]

submit_job(script_path: str, sim_id: str, slurm: bool = True, afterok: int | None = None, verbose: int = 0) Tuple[int, str, str][source]

Submit the job.

Parameters:
  • script_path (str) – the job input script.

  • sim_id (str) – simulation id.

  • slurm (bool, optional) – [NotImplemented] if True will write a SLURM script. Defaults to True.

  • afterok (int, optional) – [NotImplemented] jobid to follow. Defaults to None.

  • verbose (int, optional) – loudness controller: - 0: print errors - 1: print errors and warnings - 2: print errors, warnings and info - 3: print errors, warnings, info and debugger messages. Defaults to 0.

Raises:

NotImplementedError – raise the error if you try to use it with SLURM Workload Manager.

Returns:

tuple containing:
  • int: the job ID.

  • str: the path where the job STDOUT is stored.

  • str: the path where the job STDERR is stored.

Return type:

Tuple[int, str, str]

write_script(cmd: str | list, sim_id: str, slurm: bool = False, nodes: int = 1, gpus: int | None = None, ntasks_per_node: int = 1, cpus_per_task: int | None = None, ntasks_per_socket: int | None = None, gres: int | str | None = None, script_path: str | None = None, job_settings: str | None = None, verbose: int = 0) str[source]

Write the JOB script file.

Parameters:
  • cmd (str | list) – job commands.

  • sim_id (str) – simulation id.

  • slurm (bool, optional) – [NotImplemented] if True will write a SLURM script. Defaults to False.

  • nodes (int, optional) – [NotImplemented] cores per node (equivalent to SLURM option --ntasks-per-node). Defaults to 1.

  • gpus (int, optional) – [NotImplemented] total number of gpus (equivalent to SLURM option --gpus).

  • None. (Defaults to) –

  • ntasks_per_node (int, optional) – [NotImplemented] request that ntasks be invoked on each node (equivalent to SLURM option --ntasks-per-node). Defaults to 1.

  • cpus_per_task (int, optional) – [NotImplemented] request that ncpus be allocated per process. This may be useful if the job is multithreaded and requires more than one CPU per task for optimal performance. (equivalent to SLURM option --cpus-per-task). Defaults to None.

  • ntasks_per_socket (int, optional) – [NotImplemented] request the maximum ntasks be invoked on each socket (equivalent to SLURM option --ntasks-per-socket). Defaults to None.

  • gres (int | str, optional) – [NotImplemented] specifies a comma-delimited list of generic consumable resources. The format of each entry on the list is “name[[:type]:count]”. (equivalent to SLURM option --gres) Defaults to None.

  • script_path (str, optional) – _description_. Defaults to None.

  • job_settings (str, optional) – [NotImplemented] jobs settings file path. Defaults to None.

  • verbose (int, optional) – loudness controller: - 0: print errors - 1: print errors and warnings - 2: print errors, warnings and info - 3: print errors, warnings, info and debugger messages Defaults to 0.

Raises:

NotImplementedError – raise the error if you try to use it with SLURM Workload Manager.

Returns:

Script file path.

Return type:

str

Submodules

Job handler functions using bash scripts.

exception BashError[source]

Bases: RuntimeError

Bash error class.

check_job_status_bash(pid: int, job_out_file: str, job_err_file: str, verbose: int = 0) Tuple[str, datetime | None][source]

Check job status bash.

Parameters:
  • pid (int) – the command PID (equivalent to job ID).

  • job_out_file (str) – the path where the job STDOUT is stored.

  • job_err_file (str) – the path where the job STDERR is stored.

  • verbose (int, optional) – loudness controller: - 0: print errors - 1: print errors and warnings - 2: print errors, warnings and info - 3: print errors, warnings, info and debugger messages. Defaults to 0.

Returns:

tuple containing:
  • str: job status.

  • datetime: the ending time if completed, None otherwise.

Return type:

Tuple[str, datetime | None]

check_out_file_mark(job_out_file: str, job_err_file: str, verbose: int = 0) Tuple[str, datetime | None][source]

Check the job status by looking at the STDOUT and STDERR files.

Parameters:
  • job_out_file (str) – the path where the job STDOUT is stored.

  • job_err_file (str) – the path where the job STDERR is stored.

  • verbose (int, optional) – loudness controller: - 0: print errors - 1: print errors and warnings - 2: print errors, warnings and info - 3: print errors, warnings, info and debugger messages. Defaults to 0.

Raises:
  • ValueError – if STDOUT file not found.

  • ValueError – if STDERR file not found.

Returns:

tuple containing:
  • str: job status.

  • datetime: the ending time if completed, None otherwise.

Return type:

Tuple[str, datetime | None]

submit_job_bash(script_path: str, sim_id: str, afterok: int | None = None, verbose: int = 0) Tuple[int, str, str][source]

Submit the job in background.

Parameters:
  • script_path (str) – the job input script.

  • sim_id (str) – simulation id.

  • afterok (int, optional) – [PlaceHolder] depended job ID to start after. Defaults to None.

  • verbose (int, optional) – loudness controller: - 0: print errors - 1: print errors and warnings - 2: print errors, warnings and info - 3: print errors, warnings, info and debugger messages. Defaults to 0.

Raises:

BashError – raise error if somethin goes wrong whit starting the job.

Returns:

tuple containing:
  • int: the command PID (equivalent to job ID).

  • str: the path where the job STDOUT is stored.

  • str: the path where the job STDERR is stored.

Return type:

Tuple[int, str, str]

write_script_bash(cmd: str | list, sim_id: str, job_settings: str | None = None, script_path: str | None = None, verbose: int = 0) str[source]

Write the bash script file.

Parameters:
  • cmd (str or list) – job commands.

  • sim_id (str) – simulation id.

  • job_settings (str, optional) – jobs settings file path. Defaults to None.

  • script_path (str, optional) – path where to save the bash script. Defaults to None.

  • verbose (int, optional) – loudness controller: - 0: print errors - 1: print errors and warnings - 2: print errors, warnings and info - 3: print errors, warnings, info and debugger messages. Defaults to 0.

Returns:

script file path.

Return type:

str

Job handeler module.

check_job_status(job_id: int, job_out_file: str, job_err_file: str, slurm: bool = True, verbose: int = 0) Tuple[str, datetime | None][source]

Check job status.

Parameters:
  • job_id (int) – the command PID (equivalent to job ID).

  • job_out_file (str) – the path where the job STDOUT is stored.

  • job_err_file (str) – the path where the job STDERR is stored.

  • slurm (bool, optional) – [NotImplemented] if True will write a SLURM script. Defaults to False.

  • verbose (int, optional) – loudness controller: - 0: print errors - 1: print errors and warnings - 2: print errors, warnings and info - 3: print errors, warnings, info and debugger messages. Defaults to 0.

Raises:

NotImplementedError – raise the error if you try to use it with SLURM Workload Manager.

Returns:

tuple containing:
  • str: job status.

  • datetime: the ending time if completed, None otherwise

Return type:

Tuple[str, datetime | None]

submit_job(script_path: str, sim_id: str, slurm: bool = True, afterok: int | None = None, verbose: int = 0) Tuple[int, str, str][source]

Submit the job.

Parameters:
  • script_path (str) – the job input script.

  • sim_id (str) – simulation id.

  • slurm (bool, optional) – [NotImplemented] if True will write a SLURM script. Defaults to True.

  • afterok (int, optional) – [NotImplemented] jobid to follow. Defaults to None.

  • verbose (int, optional) – loudness controller: - 0: print errors - 1: print errors and warnings - 2: print errors, warnings and info - 3: print errors, warnings, info and debugger messages. Defaults to 0.

Raises:

NotImplementedError – raise the error if you try to use it with SLURM Workload Manager.

Returns:

tuple containing:
  • int: the job ID.

  • str: the path where the job STDOUT is stored.

  • str: the path where the job STDERR is stored.

Return type:

Tuple[int, str, str]

write_script(cmd: str | list, sim_id: str, slurm: bool = False, nodes: int = 1, gpus: int | None = None, ntasks_per_node: int = 1, cpus_per_task: int | None = None, ntasks_per_socket: int | None = None, gres: int | str | None = None, script_path: str | None = None, job_settings: str | None = None, verbose: int = 0) str[source]

Write the JOB script file.

Parameters:
  • cmd (str | list) – job commands.

  • sim_id (str) – simulation id.

  • slurm (bool, optional) – [NotImplemented] if True will write a SLURM script. Defaults to False.

  • nodes (int, optional) – [NotImplemented] cores per node (equivalent to SLURM option --ntasks-per-node). Defaults to 1.

  • gpus (int, optional) – [NotImplemented] total number of gpus (equivalent to SLURM option --gpus).

  • None. (Defaults to) –

  • ntasks_per_node (int, optional) – [NotImplemented] request that ntasks be invoked on each node (equivalent to SLURM option --ntasks-per-node). Defaults to 1.

  • cpus_per_task (int, optional) – [NotImplemented] request that ncpus be allocated per process. This may be useful if the job is multithreaded and requires more than one CPU per task for optimal performance. (equivalent to SLURM option --cpus-per-task). Defaults to None.

  • ntasks_per_socket (int, optional) – [NotImplemented] request the maximum ntasks be invoked on each socket (equivalent to SLURM option --ntasks-per-socket). Defaults to None.

  • gres (int | str, optional) – [NotImplemented] specifies a comma-delimited list of generic consumable resources. The format of each entry on the list is “name[[:type]:count]”. (equivalent to SLURM option --gres) Defaults to None.

  • script_path (str, optional) – _description_. Defaults to None.

  • job_settings (str, optional) – [NotImplemented] jobs settings file path. Defaults to None.

  • verbose (int, optional) – loudness controller: - 0: print errors - 1: print errors and warnings - 2: print errors, warnings and info - 3: print errors, warnings, info and debugger messages Defaults to 0.

Raises:

NotImplementedError – raise the error if you try to use it with SLURM Workload Manager.

Returns:

Script file path.

Return type:

str

Additiona ussefule rutine for jobs handler.

output_job_tail(stdout_file: str, n: int = 10, add_time: bool = True, msg_type: str = 'info')[source]

Follow the STDOUT file and print the last line.

Parameters:
  • stdout_file (str) – path to the STDOUT file.

  • n (int, optional) – number of line to print. Defaults to 10.

  • add_time (bool, optional) – show the date. Defaults to True.

  • msg_type (str, optional) – type of message: - ‘error’ or ‘e’ : errors messages - ‘warning’ or ‘w’ : warning messages - ‘info’ or ‘i’ : info messages - ‘debug’ or ‘d’ : debug messages. Defaults to “info”.