Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix_phase_called_twice] fix bug that ensure when activate an experim… #357

Merged
merged 2 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions src_py/apiServer/experiment_flow_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def print_test(in_str : str , enable = True):
api_server_instance.run_current_experiment_phase() # blocking until phase is completed
stats_train = api_server_instance.get_experiment_flow(experiment_name).generate_stats()

next_expertiment_phase_exist = api_server_instance.next_experiment_phase()
assert next_expertiment_phase_exist, "No next experiment phase found"
api_server_instance.next_experiment_phase()
assert api_server_instance.next_expertiment_phase_exist, "No next experiment phase found"
api_server_instance.run_current_experiment_phase() # blocking until phase is completed
stats_predict = api_server_instance.get_experiment_flow(experiment_name).generate_stats()

Expand Down