Python tools to read SLURM job parameters.
Pip
pip install slurmio
Conda
conda install -c conda-forge slurmio
From source:
git clone https://github.com/neuroinformatics-unit/slurmio
cd slurmio
pip install .
>>> from slurmio import SlurmJobParameters
>>> slurm_parameters = SlurmJobParameters()
>>> slurm_parameters.job_id
994986
>>> slurm_parameters.job_name
'bash'
>>> slurm_parameters.partition
'cpu'
>>> slurm_parameters.requested_cores
10
>>> slurm_parameters.allocated_cores
10
>>> slurm_parameters.requested_nodes
10
>>> slurm_parameters.allocated_nodes
10
>>> slurm_parameters.requested_memory
10240 # in bytes
>>> slurm_parameters.allocated_memory
10240 # in bytes