Skip to content

Commit

Permalink
[fix_phase_called_twice] fix bug that ensure when activate an experim…
Browse files Browse the repository at this point in the history
…ent - don't allow calling the same phase twice
  • Loading branch information
NoaShapira8 authored and leondavi committed Jul 4, 2024
1 parent 62330e9 commit 3b0aa74
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
10 changes: 7 additions & 3 deletions src_py/apiServer/apiServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __init__(self):
self.experiments_dict = {}
self.current_exp = None
self.apiserver_event_sync = EventSync() # pay attention! there are two kinds of syncs one for experiment phase events and one for api-server events
self.next_expertiment_phase_exist = True # flag to check if there are more phases to run

# Create a new folder for the results:
Path(EXPERIMENT_RESULTS_PATH).mkdir(parents=True, exist_ok=True)
Expand Down Expand Up @@ -153,6 +154,7 @@ def send_data_to_sources(self, csv_dataset: CsvDataSet, experiment_phase: Experi
LOG_INFO("Data is ready in sources")

def run_current_experiment_phase(self):
assert self.next_expertiment_phase_exist, "experiment override is not supported!" # don't allow calling the same phase twice
current_exp_phase = self.current_exp.get_current_experiment_phase()
LOG_INFO(f"Experiment phase: {current_exp_phase.get_name()} of type {current_exp_phase.get_phase_type()} starts running...")
csv_dataset_inst = self.current_exp.get_csv_dataset()
Expand All @@ -179,7 +181,8 @@ def run_current_experiment_phase(self):
self.communication_stats()

LOG_INFO(f"Phase of {current_exp_phase.get_name()} {current_exp_phase.get_phase_type()} completed")


self.next_expertiment_phase_exist = False


def next_experiment_phase(self):
Expand All @@ -189,8 +192,9 @@ def next_experiment_phase(self):
current_exp_flow.current_exp_phase_index += 1
if not self.experiment_phase_is_valid():
LOG_WARNING("No more phases to run")
return False
return True
self.next_expertiment_phase_exist = False
else:
self.next_expertiment_phase_exist = True

def communication_stats(self):
assert self.experiment_phase_is_valid(), "No valid experiment phase"
Expand Down
5 changes: 2 additions & 3 deletions src_py/apiServer/experiment_flow_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ def print_test(in_str : str):
experiment_name = "test_exp"
api_server_instance.initialization(experiment_name, dc_json , connmap_json, exp_flow_json) # start to debug
api_server_instance.send_jsons_to_devices()

next_expertiment_phase_exist = True

api_server_instance.run_current_experiment_phase() # blocking - deppended acks from mainserver
stats = api_server_instance.get_experiment_flow(experiment_name).generate_stats()
stats.get_communication_stats_workers()
Expand All @@ -40,7 +39,7 @@ def print_test(in_str : str):
stats.get_communication_stats_main_server()
stats.get_loss_ts()
stats.get_min_loss()
next_expertiment_phase_exist = api_server_instance.next_experiment_phase()
api_server_instance.next_experiment_phase()
api_server_instance.run_current_experiment_phase()
stats = api_server_instance.get_experiment_flow(experiment_name).generate_stats()
confusion_matrix_source_dict, confusion_matrix_worker_dict = stats.get_confusion_matrices()
Expand Down

0 comments on commit 3b0aa74

Please sign in to comment.