in cookbooks/aws-parallelcluster-slurm/files/default/head_node_slurm/slurm/pcluster_custom_slurm_settings_include_file_generator.py [0:0]
def _render_parameter(param: Dict) -> str:
"""
Render string to represent a parameter in the Slurm configuration.
:param param: dictionary containing the parameter structure.
:return: string to be included in the Slurm configuration file.
"""
first_subparam = {}
# Some complex parameters require a specific subparameter to be defined first in the line
# (e.g. the NodeName parameter in the node definition)
for key, value in param.items():
# Here we assume that the users do not pass more than one of these parameters in the same dictionary.
if key.lower() in ["nodename", "partitionname", "nodeset", "downnodes"]:
if not first_subparam:
first_subparam[key] = value
else:
log.warning(
"Warning! Another subparameter to be placed in first position was already found: %s", first_subparam
)
remaining_subparams = {key: value for key, value in param.items() if key not in first_subparam}
output_string = ""
# The first loop will either loop over a single parameter or not run at all
for key, value in first_subparam.items():
output_string = " ".join([output_string, f"{key}={value}"])
for key, value in remaining_subparams.items():
output_string = " ".join([output_string, f"{key}={value}"])
# Here the leading whitespace introduced by the first join() is removed
return output_string.lstrip()