Commit 142618a5 authored by Alan Taylor's avatar Alan Taylor

PEP8 tidy

parent ca4112cf
......@@ -26,19 +26,19 @@ along with dtr. If not, see <http://www.gnu.org/licenses/>.
------------------------------------------------------------------------------
"""
import concurrent.futures as cf # ProcessPoolExecutor
import datetime # timedelta
import hashlib # sha256
import multiprocessing as mp # cpu_count, Queue
import os # path.isdir, path.isfile
import subprocess # DEVNULL, Popen
import sys # exit
import time # time
import concurrent.futures as cf # ProcessPoolExecutor
import datetime # timedelta
import hashlib # sha256
import multiprocessing as mp # cpu_count, Queue
import os # path.isdir, path.isfile
import subprocess # DEVNULL, Popen
import sys # exit
import time # time
import dtr_data_struct as ds # FILENAME_BENCHMARK, FILENAME_BENCHMARK_CACHE
import dtr_file_io as fio # backup_render, benchmark_cache_read,
# benchmark_cache_write
import dtr_utils as utils # package_filename_for_cygwin
import dtr_data_struct as ds # FILENAME_BENCHMARK, FILENAME_BENCHMARK_CACHE
import dtr_file_io as fio # backup_render, benchmark_cache_read,
# benchmark_cache_write
import dtr_utils as utils # package_filename_for_cygwin
##############################################################################
......@@ -70,6 +70,7 @@ def _bench_info(ntb, ips):
else:
print('running benchmarks on', l_ntb, 'of', l_ips, 'nodes')
def _nodes_to_assess(node_ips_specified):
"""
work out which nodes need to be benchmarked, taking into consideration
......@@ -132,6 +133,7 @@ def _nodes_to_assess(node_ips_specified):
return nodes_to_benchmark, hash_cached, bench_cached
def benchmark_new_nodes(nodes_specified):
"""
run benchmarks asynchronously on all nodes for which we do not have
......@@ -190,6 +192,7 @@ def benchmark_new_nodes(nodes_specified):
return [x for x in bench_res if x[0] in ips_specified]
def _benchmark_render_node(rni):
"""
run benchmark on given node, completion time is returned using the queue
......@@ -217,21 +220,22 @@ def _benchmark_render_node(rni):
# transfer benchmark Blender file to remote node
on_this_node = rni.username + '@' + rni.ip_address
remote_filename = on_this_node + ':~'
with subprocess.Popen(['rsync', '-acq', ds.FILENAME_BENCHMARK, remote_filename], \
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) as proc:
with subprocess.Popen(['rsync', '-acq', ds.FILENAME_BENCHMARK, remote_filename],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) as proc:
proc.wait()
filename = utils.package_filename_for_cygwin(rni.opsys, ds.FILENAME_BENCHMARK)
render_the_benchmark = rni.binloc + ' -b ' + filename + ' -f 1'
start = time.time()
with subprocess.Popen(['ssh', on_this_node, render_the_benchmark], \
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) as proc:
with subprocess.Popen(['ssh', on_this_node, render_the_benchmark],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) as proc:
proc.wait()
time_diff = int(time.time() - start)
return rni.ip_address, time_diff
def display_bench_cache(nodes_specified):
"""
display contents of benchmark cache
......@@ -260,7 +264,8 @@ def display_bench_cache(nodes_specified):
mx_ip_len = max(len(x[0]) for x in bench_cached)
for i in bench_cached:
in_use = 'active' if i[0] in ips_specified else ''
print('cached: node', i[0].rjust(mx_ip_len), 'benchmark time', \
print(
'cached: node', i[0].rjust(mx_ip_len), 'benchmark time',
str(datetime.timedelta(seconds=int(i[1]))), in_use)
elif cache_present and bench_present:
......@@ -275,5 +280,6 @@ def display_bench_cache(nodes_specified):
mx_ip_len = max(len(x[0]) for x in bench_cached)
for i in bench_cached:
in_use = 'active' if i[0] in ips_specified else ''
print('cached: node', i[0].rjust(mx_ip_len), 'benchmark time', \
print(
'cached: node', i[0].rjust(mx_ip_len), 'benchmark time',
str(datetime.timedelta(seconds=i[1])), in_use)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment