AstraLog-HPC
Loading...
Searching...
No Matches
JobWriter Class Reference

Fills a SLURM job template ({{TOKEN}} placeholders) and writes it to disk. More...

#include <JobScheduler.hpp>

Collaboration diagram for JobWriter:
Collaboration graph

Classes

struct  EnvVars
 Env-var values cached at construction time. More...
 

Public Member Functions

 JobWriter (std::string sensors_path, std::string rules_path)
 Reads the required env vars (see file-level table).
 
int write_job (const std::string &batch_path, int num_proc=1)
 Instantiates the template and writes job_<id>.slurm to disk.
 

Private Member Functions

void set_env ()
 Reads required env vars into env; throws on the first missing one.
 

Private Attributes

int job_counter = 0
 
std::string sensors_path
 
std::string rules_path
 
EnvVars env
 

Detailed Description

Fills a SLURM job template ({{TOKEN}} placeholders) and writes it to disk.

Env vars are read once in the constructor. Each write_job() call replaces all tokens, writes job_<id>.slurm next to the batch file, and returns the incrementing job id.

Constructor & Destructor Documentation

◆ JobWriter()

JobWriter::JobWriter ( std::string  sensors_path,
std::string  rules_path 
)

Reads the required env vars (see file-level table).

Exceptions
astralog::ConfigErrorif any required env var is missing.
Here is the call graph for this function:

Member Function Documentation

◆ set_env()

void JobWriter::set_env ( )
private

Reads required env vars into env; throws on the first missing one.

Here is the caller graph for this function:

◆ write_job()

int JobWriter::write_job ( const std::string &  batch_path,
int  num_proc = 1 
)

Instantiates the template and writes job_<id>.slurm to disk.

Key tokens: {{BATCH_FILE}} becomes REMOTE_WORKDIR/batch_<id>.<ext> (the per-job rename avoids concurrent-job collisions); sensors/rules keep their names; outputs are fixed names under REMOTE_OUTPUT_DIR.

Parameters
batch_pathLocal path to the batch input file for this job.
num_procMPI task count; fills the {{NTASKS}} token (#SBATCH --ntasks). Defaults to 1 (single-task job) when the caller doesn't shard.
Returns
The job id (0-based, incremented on each call).
Exceptions
astralog::IoErrorif the template or output file cannot be opened.
Here is the caller graph for this function:

Member Data Documentation

◆ env

EnvVars JobWriter::env
private

◆ job_counter

int JobWriter::job_counter = 0
private

◆ rules_path

std::string JobWriter::rules_path
private

◆ sensors_path

std::string JobWriter::sensors_path
private

The documentation for this class was generated from the following files: