Skip to content

Commit 50ee17f

Browse files
committed
Move script part into if __name == "__main__"
1 parent 4ad8d95 commit 50ee17f

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

roles/slurm/files/update_config.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,19 @@ def get_node_configs(limits, shapes, mgmt_info):
5959
yield config
6060

6161

62-
# TODO Make sure that any nodes which are no longer managed due to service limit reductions are terminated.
62+
if __name__ == "__main__":
63+
# TODO Make sure that any nodes which are no longer managed due to service limit reductions are terminated.
6364

64-
slurm_conf_filename = "/mnt/shared/etc/slurm/slurm.conf"
65+
slurm_conf_filename = "/mnt/shared/etc/slurm/slurm.conf"
6566

66-
node_config = "\n".join(get_node_configs(get_limits(), get_shapes(), get_mgmt_info()))
67+
node_config = "\n".join(get_node_configs(get_limits(), get_shapes(), get_mgmt_info()))
6768

68-
chop = re.compile('(?<=# STARTNODES\n)(.*?)(?=\n?# ENDNODES)', re.DOTALL)
69+
chop = re.compile('(?<=# STARTNODES\n)(.*?)(?=\n?# ENDNODES)', re.DOTALL)
6970

70-
with open(slurm_conf_filename) as f:
71-
all_config = f.read()
71+
with open(slurm_conf_filename) as f:
72+
all_config = f.read()
7273

73-
new_config = chop.sub('{}'.format(node_config), all_config)
74+
new_config = chop.sub('{}'.format(node_config), all_config)
7475

75-
with open(slurm_conf_filename, "w") as f:
76-
f.write(new_config)
76+
with open(slurm_conf_filename, "w") as f:
77+
f.write(new_config)

0 commit comments

Comments
 (0)