-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b50c394
commit 3574d77
Showing
1 changed file
with
20 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,41 @@ | ||
import time | ||
import uuid | ||
|
||
from config import settings | ||
from fedn import APIClient | ||
|
||
DISCOVER_HOST = "127.0.0.1" | ||
DISCOVER_PORT = 8092 | ||
client = APIClient(DISCOVER_HOST, DISCOVER_PORT) | ||
client = APIClient( | ||
host=settings["DISCOVER_HOST"], | ||
port=settings["DISCOVER_PORT"], | ||
secure=settings["SECURE"], | ||
verify=settings["VERIFY"], | ||
token=settings["ADMIN_TOKEN"], | ||
) | ||
|
||
if __name__ == "__main__": | ||
# Run six sessions, each with 100 rounds. | ||
num_sessions = 6 | ||
for s in range(num_sessions): | ||
for s in range(settings["N_SESSIONS"]): | ||
active_model = client.get_active_model() | ||
session_config = { | ||
"helper": "numpyhelper", | ||
"id": str(uuid.uuid4()), | ||
"aggregator": "fedopt", | ||
"id": f"async-test-{s+1}-{str(uuid.uuid4())[:4]}", | ||
"aggregator": "fedavg", | ||
"round_timeout": 20, | ||
"rounds": 100, | ||
"validate": False, | ||
"rounds": settings["N_ROUNDS"], | ||
"validate": True, | ||
"model_id": active_model["model"], | ||
} | ||
|
||
session = client.start_session(**session_config) | ||
if session["success"] is False: | ||
if session["message"] != "Session started": | ||
print(session["message"]) | ||
exit(0) | ||
|
||
print("Started session: {}".format(session)) | ||
|
||
# Wait for session to finish | ||
while not client.session_is_finished(session_config["id"]): | ||
time.sleep(2) | ||
t_sleep = 2 | ||
session_status = client.get_session_status(session_config["id"]) | ||
print(f"Session status: {session_status}. Sleeping for {t_sleep}") | ||
time.sleep(t_sleep) |