From 9f6f5cf75bf8d54dc644138b2a714f3ac2f32297 Mon Sep 17 00:00:00 2001 From: salotz Date: Tue, 17 Apr 2018 14:52:06 -0400 Subject: [PATCH] tested seh non-timed and the example script for getting ancestors --- .../seh_tppu_unbinding/analysis/walker_lineage.py | 12 ++++++------ examples/seh_tppu_unbinding/we.py | 14 +++++++++++++- wepy/analysis/tree.py | 6 +++--- wepy/reporter/dashboard.py | 11 +++++++---- wepy/work_mapper/mapper.py | 4 ++-- 5 files changed, 31 insertions(+), 16 deletions(-) diff --git a/examples/seh_tppu_unbinding/analysis/walker_lineage.py b/examples/seh_tppu_unbinding/analysis/walker_lineage.py index a05258a6..752e54a0 100644 --- a/examples/seh_tppu_unbinding/analysis/walker_lineage.py +++ b/examples/seh_tppu_unbinding/analysis/walker_lineage.py @@ -8,8 +8,8 @@ if sys.argv[1] == '-h' or sys.argv[1] == '--help': print("walker_lineage.py run_index walker_index output_DCD_path") else: - run_idx = sys.argv[1] - walker_idx = sys.argv[2] + run_idx = int(sys.argv[1]) + walker_idx = int(sys.argv[2]) dcd_path = sys.argv[3] outputs_dir = osp.realpath('../outputs') @@ -22,15 +22,15 @@ wepy_h5.open() - cycle_idx = wepy_h5.traj(run_idx, walker_idx)['positions'].shape[0] + cycle_idx = wepy_h5.traj(run_idx, walker_idx)['positions'].shape[0] - 1 resampling_panel = wepy_h5.run_resampling_panel(run_idx) - parent_panel = WExplore1.DECISION.parent_panel(resampling_panel) - parent_table = WExplore1.DECISION.net_parent_panel(parent_panel) + parent_panel = WExplore1Resampler.DECISION.parent_panel(resampling_panel) + parent_table = WExplore1Resampler.DECISION.net_parent_table(parent_panel) lineage = ancestors(parent_table, cycle_idx, walker_idx) - mdj_traj = wepy_h5.trace_to_mdtraj(lineage) + mdj_traj = wepy_h5.run_trace_to_mdtraj(run_idx, lineage) mdj_traj.save_dcd(dcd_path) diff --git a/examples/seh_tppu_unbinding/we.py b/examples/seh_tppu_unbinding/we.py index 36d4be45..a91a1211 100644 --- a/examples/seh_tppu_unbinding/we.py +++ b/examples/seh_tppu_unbinding/we.py @@ -103,6 +103,10 @@ # standard reporters from wepy.reporter.hdf5 import WepyHDF5Reporter +# a reporter to show a dashboard in plaintext of current summarized +# results of the simulation +from wepy.reporter.dashboard import WExploreDashboardReporter + ## PARAMETERS # OpenMM simulation parameters @@ -367,6 +371,14 @@ def main(n_runs, n_cycles, steps, n_walkers, n_workers=1, debug_prints=False, se all_atoms_rep_freq=ALL_ATOMS_SAVE_FREQ ) + dashboard_reporter = WExploreDashboardReporter('./outputs/wepy.dash.txt', mode='w', + step_time=STEP_SIZE.value_in_unit(unit.second), + max_n_regions=resampler.max_n_regions, + max_region_sizes=resampler.max_region_sizes, + bc_cutoff_distance=ubc.cutoff_distance) + + reporters = [hdf5_reporter, dashboard_reporter] + ## The work mapper # we use a mapper that uses GPUs @@ -388,7 +400,7 @@ def main(n_runs, n_cycles, steps, n_walkers, n_workers=1, debug_prints=False, se resampler=resampler, boundary_conditions=ubc, work_mapper=work_mapper, - reporters=[hdf5_reporter]) + reporters=reporters) ### RUN the simulation diff --git a/wepy/analysis/tree.py b/wepy/analysis/tree.py index d23e7031..e45142fb 100644 --- a/wepy/analysis/tree.py +++ b/wepy/analysis/tree.py @@ -28,9 +28,9 @@ def ancestors(parent_matrix, cycle_idx, walker_idx, ancestor_cycle=0): previous_walker = walker_idx - for cycle_idx in range(cycle_idx, ancestor_cycle, -1): - previous_walker = parent_matrix[cycle_idx][previous_walker] - previous_point = (cycle_idx - 1, previous_walker) + for curr_cycle_idx in range(cycle_idx, ancestor_cycle, -1): + previous_walker = parent_matrix[curr_cycle_idx][previous_walker] + previous_point = (curr_cycle_idx - 1, previous_walker) ancestors.insert(0, previous_point) return ancestors diff --git a/wepy/reporter/dashboard.py b/wepy/reporter/dashboard.py index 00bac5d1..9f04803a 100644 --- a/wepy/reporter/dashboard.py +++ b/wepy/reporter/dashboard.py @@ -48,6 +48,7 @@ class WExploreDashboardReporter(FileReporter): Average Resampling Time: {avg_resampling_time} Average Cycle Time: {avg_cycle_time} Worker Avg. Segment Times: + {worker_avg_segment_time} Warping Log: @@ -350,6 +351,8 @@ def update_performance_values(self, cycle_idx, n_steps, worker_segment_times, 'worker_idx', 'segment_time')) # the aggregated table for the workers self.worker_agg_table = worker_df.groupby('worker_idx')[['segment_time']].aggregate(np.mean) + self.worker_agg_table.rename(columns={'segment_time' : 'avg_segment_time (s)'}, + inplace=True) # log of the components times self.cycle_runner_times.append(cycle_runner_time) @@ -419,13 +422,13 @@ def dashboard_string(self): branching_table_str = branching_table_df.to_string() # log of warp events - warp_table_colnames = ('walker_idx', 'weight', 'time') + warp_table_colnames = ('walker_idx', 'weight', 'time (s)') warp_table_df = pd.DataFrame(self.warp_records, columns=warp_table_colnames) warp_table_str = warp_table_df.to_string() # log of cycle times - cycle_table_colnames = ('cycle_time', 'runner_time', 'boundary_conditions_time', - 'resampling_time') + cycle_table_colnames = ('cycle_time (s)', 'runner_time (s)', 'boundary_conditions_time (s)', + 'resampling_time (s)') cycle_table_df = pd.DataFrame({'cycle_times' : self.cycle_compute_times, 'runner_time' : self.cycle_runner_times, 'boundary_conditions_time' : self.cycle_bc_times, @@ -435,7 +438,7 @@ def dashboard_string(self): # log of workers performance - worker_table_colnames = ('cycle_idx', 'n_steps', 'worker_idx', 'segment_time',) + worker_table_colnames = ('cycle_idx', 'n_steps', 'worker_idx', 'segment_time (s)',) worker_table_df = pd.DataFrame(self.worker_records, columns=worker_table_colnames) worker_table_str = worker_table_df.to_string() diff --git a/wepy/work_mapper/mapper.py b/wepy/work_mapper/mapper.py index 3477b779..4943a61d 100644 --- a/wepy/work_mapper/mapper.py +++ b/wepy/work_mapper/mapper.py @@ -46,7 +46,7 @@ def __init__(self, num_workers=None, worker_type=None, debug_prints=False): self.num_workers = num_workers - self.worker_segment_times = {worker_idx : [] for i in range(num_workers)} + self.worker_segment_times = {i : [] for i in range(self.num_workers)} # choose the type of the worker if worker_type is None: @@ -161,7 +161,7 @@ def map(self, *args, debug_prints=False): # save the task run times, so they can be accessed if desired, # after clearing the task times from the last mapping - self.worker_segment_times = {worker_idx : [] for i in range(num_workers)} + self.worker_segment_times = {i : [] for i in range(self.num_workers)} for task_idx, worker_idx, task_time, result in results: self.worker_segment_times[worker_idx].append(task_time)