Skip to content

Commit

Permalink
Fix simulator result path (#2967)
Browse files Browse the repository at this point in the history
  • Loading branch information
YuanTingHsieh authored Sep 27, 2024
1 parent 23c471a commit db6c29c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
"outputs": [],
"source": [
"%load_ext tensorboard\n",
"%tensorboard --logdir /tmp/nvflare/workspaces/xgboost_workspace_5_histogram_uniform_split_uniform_lr/simulate_job/tb_events"
"%tensorboard --logdir /tmp/nvflare/workspaces/xgboost_workspace_5_histogram_uniform_split_uniform_lr/server/simulate_job/tb_events"
]
}
],
Expand All @@ -158,7 +158,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.17"
"version": "3.12.6"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
import tensorflow as tf

# simulator workspace
client_results_root = "./workspaces/xgboost_workspace_"
client_num_list = [5, 20]
client_pre = "app_site-"
centralized_path = "./workspaces/centralized_1_1/events.*"
CLIENT_RESULTS_ROOT = "./workspaces/xgboost_workspace_"
CLIENT_NUM_LIST = [5, 20]
CENTRAL_EVENT_PATH = "./workspaces/centralized_1_1/events.*"

# bagging and cyclic need different handle
experiments_bagging = {
Expand Down Expand Up @@ -75,6 +74,7 @@ def read_eventfile(filepath, tags=["AUC"]):


def add_eventdata(data, config, filepath, tag="AUC"):
print(f"adding {filepath}")
event_data = read_eventfile(filepath, tags=[tag])
assert len(event_data[tag]) > 0, f"No data for key {tag}"

Expand All @@ -92,40 +92,41 @@ def add_eventdata(data, config, filepath, tag="AUC"):
print(f"added {len(event_data[tag])} entries for {tag}")


def _get_record_path(config: str, site: str) -> str:
return os.path.join(CLIENT_RESULTS_ROOT + config, f"site-{site}", "simulate_job", f"app_site-{site}", "events.*")


def _find_tb_event_file(record_path: str):
eventfile = glob.glob(record_path, recursive=True)
assert len(eventfile) == 1, f"No unique event file found using {record_path=} {eventfile=}!"
eventfile = eventfile[0]
return eventfile


def main():
plt.figure()

for client_num in client_num_list:
for client_num in CLIENT_NUM_LIST:
plt.figure
plt.title(f"{client_num} client experiments")
# add event files
data = {"Config": [], "Round": [], "AUC": []}
# add centralized result
eventfile = glob.glob(centralized_path, recursive=True)
assert len(eventfile) == 1, "No unique event file found!" + eventfile
eventfile = eventfile[0]
print("adding", eventfile)
eventfile = _find_tb_event_file(CENTRAL_EVENT_PATH)
add_eventdata(data, "centralized", eventfile, tag="AUC")

# pick first client for bagging experiments
site = 1
for config, exp in experiments_bagging[client_num].items():
record_path = os.path.join(client_results_root + config, "simulate_job", client_pre + str(site), "events.*")
eventfile = glob.glob(record_path, recursive=True)
assert len(eventfile) == 1, "No unique event file found!"
eventfile = eventfile[0]
print("adding", eventfile)
record_path = _get_record_path(config, str(site))
eventfile = _find_tb_event_file(record_path)
add_eventdata(data, config, eventfile, tag=exp["tag"])

# Combine all clients' records for cyclic experiments
for site in range(1, client_num + 1):
for config, exp in experiments_cyclic[client_num].items():
record_path = os.path.join(
client_results_root + config, "simulate_job", client_pre + str(site), "events.*"
)
eventfile = glob.glob(record_path, recursive=True)
assert len(eventfile) == 1, f"No unique event file found under {record_path}!"
eventfile = eventfile[0]
print("adding", eventfile)
record_path = _get_record_path(config, str(site))
eventfile = _find_tb_event_file(record_path)
add_eventdata(data, config, eventfile, tag=exp["tag"])

sns.lineplot(x="Round", y="AUC", hue="Config", data=data)
Expand Down

0 comments on commit db6c29c

Please sign in to comment.