Skip to content

Commit 94d2a72

Browse files
author
Himani Anil Deshpande
committed
[SlurmTopo] cookstyle
1 parent 01047ac commit 94d2a72

File tree

5 files changed

+22
-27
lines changed

5 files changed

+22
-27
lines changed

cookbooks/aws-parallelcluster-slurm/attributes/slurm_attributes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@
2727
default['cluster']['pyxis']['runtime_path'] = '/run/pyxis'
2828

2929
# Block Topology Plugin
30-
default['cluster']['slurm']['block_topology']['force_configuration'] = false
30+
default['cluster']['slurm']['block_topology']['force_configuration'] = false

cookbooks/aws-parallelcluster-slurm/files/default/head_node_slurm/slurm/pcluster_topology_generator.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ def _is_gb200(instance_type):
5757
return instance_type is not None and instance_type.split(".")[0] == P6E_GB200
5858

5959

60-
def generate_topology_config_file(
60+
def generate_topology_config_file( # noqa: C901
6161
output_file: str, input_file: str, block_sizes: str, force_configuration: bool
62-
): # noqa: C901
62+
):
6363
"""
6464
Generate Topology configuration file.
6565
@@ -84,13 +84,10 @@ def generate_topology_config_file(
8484

8585
# Retrieve capacity info from the queue_name, if there
8686
queue_capacity_type = CAPACITY_TYPE_MAP.get(queue_config.get("CapacityType", "ONDEMAND"))
87-
if not _is_capacity_block(queue_capacity_type):
88-
if force_configuration:
89-
# We ignore this check if force_configuration option is used
90-
pass
91-
else:
92-
log.info("ParallelCluster does not create topology for %s", queue_capacity_type)
93-
continue
87+
if not _is_capacity_block(queue_capacity_type) and not force_configuration:
88+
# We ignore this check when force_configuration option is used.
89+
log.info("ParallelCluster does not create topology for %s", queue_capacity_type)
90+
continue
9491

9592
for compute_resource_config in queue_config["ComputeResources"]:
9693
compute_resource_name = compute_resource_config["Name"]

cookbooks/aws-parallelcluster-slurm/resources/block_topology/partial/_block_topology_common.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,5 @@ def topology_generator_command_args
7474
def topology_generator_extra_args
7575
if ['true', 'yes', true].include?(node['cluster']['slurm']['block_topology']['force_configuration'])
7676
" --force-configuration"
77-
else
78-
nil
7977
end
80-
end
78+
end

cookbooks/aws-parallelcluster-slurm/spec/unit/resources/block_topology_spec.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ def self.update(chef_run)
6161
.with(group: 'root')
6262
.with(mode: '0644')
6363
end
64-
command = "#{cookbook_env}/bin/python #{script_dir}/slurm/pcluster_topology_generator.py" \
64+
command = "#{cookbook_env}/bin/python #{script_dir}/slurm/pcluster_topology_generator.py" \
6565
" --output-file #{slurm_install_dir}/etc/topology.conf" \
6666
" --block-sizes #{block_sizes}" \
6767
" --input-file #{cluster_config}"
68-
if ['true', 'yes', true].include?(force_configuration)
69-
command_to_exe = "#{command}#{force_configuration_extra_args}"
70-
else
71-
command_to_exe = "#{command}"
72-
end
68+
command_to_exe = if ['true', 'yes', true].include?(force_configuration)
69+
"#{command}#{force_configuration_extra_args}"
70+
else
71+
"#{command}"
72+
end
7373
it 'generates topology config when block sizes are present' do
7474
expect(chef_run).to run_execute('generate_topology_config')
7575
.with(command: command_to_exe)
@@ -115,11 +115,11 @@ def self.update(chef_run)
115115
" --output-file #{slurm_install_dir}/etc/topology.conf" \
116116
" --input-file #{cluster_config}"\
117117
"#{topo_command_args}"
118-
if ['true', 'yes', true].include?(force_configuration)
119-
command_to_exe = "#{command}#{force_configuration_extra_args}"
120-
else
121-
command_to_exe = "#{command}"
122-
end
118+
command_to_exe = if ['true', 'yes', true].include?(force_configuration)
119+
"#{command}#{force_configuration_extra_args}"
120+
else
121+
"#{command}"
122+
end
123123

124124
it 'creates the topology configuration template' do
125125
expect(chef_run).to create_template("#{slurm_install_dir}/etc/slurm_parallelcluster_topology.conf")
@@ -132,12 +132,12 @@ def self.update(chef_run)
132132
if topo_command_args.nil?
133133
it 'update or cleanup topology.conf when block sizes are present' do
134134
expect(chef_run).not_to run_execute('update or cleanup topology.conf')
135-
.with(command: command_to_exe)
135+
.with(command: command_to_exe)
136136
end
137137
else
138138
it 'update or cleanup topology.conf when block sizes are present' do
139139
expect(chef_run).to run_execute('update or cleanup topology.conf')
140-
.with(command: command_to_exe)
140+
.with(command: command_to_exe)
141141
end
142142
end
143143

test/unit/slurm/test_topology_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def test_cleanup_topology_config_file(mocker, tmpdir, file_exists):
6767
("capacity-block", True),
6868
("on-demand", False),
6969
("spot", False),
70-
("anay-value", False),
70+
("any-value", False),
7171
("bla-capacity-block-bla", False),
7272
],
7373
)

0 commit comments

Comments
 (0)