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 #369

Merged
merged 5 commits into from
Jul 14, 2024
Merged
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
48 changes: 25 additions & 23 deletions src_py/apiServer/apiServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,35 +154,37 @@ 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()
events_sync_inst = self.current_exp.get_events_sync()

send_jsons_event = self.apiserver_event_sync.get_event_status(EventSync.SEND_JSONS)
assert send_jsons_event == EventSync.DONE, "Jsons not sent to devices yet"
if not self.next_expertiment_phase_exist: # don't allow calling the same phase twice
LOG_WARNING("experiment override is not supported!")
else:
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()
events_sync_inst = self.current_exp.get_events_sync()

send_jsons_event = self.apiserver_event_sync.get_event_status(EventSync.SEND_JSONS)
assert send_jsons_event == EventSync.DONE, "Jsons not sent to devices yet"

self.send_data_to_sources(csv_dataset_inst, current_exp_phase, events_sync_inst)
self.send_data_to_sources(csv_dataset_inst, current_exp_phase, events_sync_inst)

events_sync_inst.set_event_wait(EventSync.UPDATE_PHASE)
self.transmitter.clients_set_phase(current_exp_phase.get_phase_type())
events_sync_inst.sync_on_event(EventSync.UPDATE_PHASE)
events_sync_inst.set_event_wait(EventSync.UPDATE_PHASE)
self.transmitter.clients_set_phase(current_exp_phase.get_phase_type())
events_sync_inst.sync_on_event(EventSync.UPDATE_PHASE)

events_sync_inst.set_event_wait(EventSync.START_CASTING)
self.transmitter.start_casting(current_exp_phase) # Source start sending data to workers
events_sync_inst.sync_on_event(EventSync.START_CASTING)
events_sync_inst.set_event_wait(EventSync.START_CASTING)
self.transmitter.start_casting(current_exp_phase) # Source start sending data to workers
events_sync_inst.sync_on_event(EventSync.START_CASTING)

LOG_INFO(f"Processing experiment phase data")
current_exp_phase.process_experiment_phase_data()
LOG_INFO(f"Processing experiment phase data completed")
LOG_INFO(f"Processing experiment phase data")
current_exp_phase.process_experiment_phase_data()
LOG_INFO(f"Processing experiment phase data completed")

LOG_INFO(f"Start generating communication statistics for {current_exp_phase.get_name()} of type {current_exp_phase.get_phase_type()}")
self.communication_stats()
LOG_INFO(f"Start generating communication statistics for {current_exp_phase.get_name()} of type {current_exp_phase.get_phase_type()}")
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
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 Down