Skip to content

Commit 500fb54

Browse files
author
Himani Anil Deshpande
committed
Adding logs and redirect python output to console
1 parent 112bc65 commit 500fb54

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,17 +211,13 @@ def get_total_min_count(input_file: str):
211211
else:
212212
message = f"Error parsing configuration file. {e}. {traceback.format_exc()}."
213213
message += f" Queue: {queue_name}" if queue_name else ""
214-
log.error(message)
214+
print(message)
215215
raise CriticalError(message)
216216
return total_min_count
217217

218218

219219
def main():
220220
try:
221-
logging.basicConfig(
222-
level=logging.INFO, format="%(asctime)s - [%(name)s:%(funcName)s] - %(levelname)s - %(message)s"
223-
)
224-
log.info("Running ParallelCluster Fleet Config Generator")
225221
parser = argparse.ArgumentParser(description="Take in fleet configuration generator related parameters")
226222
parser.add_argument(
227223
"--input-file",
@@ -233,8 +229,12 @@ def main():
233229
exclusive_group.add_argument("--total-min-count", help="Gets the total min count of Scheduler", action='store_true')
234230
args = parser.parse_args()
235231
if args.total_min_count:
236-
log.info(f"The total MinCount of cluster is {get_total_min_count(args.input_file)}")
232+
print(f"The total MinCount of cluster is {get_total_min_count(args.input_file)}")
237233
else:
234+
logging.basicConfig(
235+
level=logging.INFO, format="%(asctime)s - [%(name)s:%(funcName)s] - %(levelname)s - %(message)s"
236+
)
237+
log.info("Running ParallelCluster Fleet Config Generator")
238238
generate_fleet_config_file(args.output_file, args.input_file)
239239
except Exception as e:
240240
log.exception("Failed to generate Fleet configuration, exception: %s", e)

cookbooks/aws-parallelcluster-slurm/libraries/helpers.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def wait_cluster_ready
179179
end
180180

181181
def get_static_node_count
182-
cmd = Mixlib::ShellOut.new("#{cookbook_virtualenv_path}/bin/python #{node['cluster']['scripts_dir']}/slurm/pcluster_fleet_config_generator.py --input-file #{node['cluster']['cluster_config_path']} --total-min-count | grep -o 'The total MinCount of cluster is =\([0-9]*\)' | cut -d'=' -f2")
182+
cmd = Mixlib::ShellOut.new("#{cookbook_virtualenv_path}/bin/python #{node['cluster']['scripts_dir']}/slurm/pcluster_fleet_config_generator.py --input-file #{node['cluster']['cluster_config_path']} --total-min-count | grep -o 'The total MinCount of cluster is \([0-9]*\)' | cut -d' ' -f7")
183183
cmd.run_command.stdout.strip
184184
end
185185

@@ -208,7 +208,7 @@ def check_for_protected_mode(fleet_status_command) # rubocop:disable Lint/Nested
208208
fleet_status_command = Shellwords.escape(
209209
"/usr/local/bin/get-compute-fleet-status.sh"
210210
)
211-
211+
Chef::Log.info("TEST LOG #{get_static_node_count}")
212212
# Example output for sinfo
213213
# sinfo -h -o '%N %t'
214214
# queue-0-dy-compute-resource-g4dn-0-[1-10],queue-1-dy-compute-resource-g4dn-1-[1-10] idle~

0 commit comments

Comments
 (0)