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

Added type hinting #155

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/algos/fl.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def __init__(
self.config["results_path"], self.node_id
)

def fed_avg(self, model_wts: List[OrderedDict[str, Tensor]]):
def fed_avg(self, model_wts: List[OrderedDict[str, Tensor]]) -> OrderedDict[str, Tensor]:
num_users = len(model_wts)
coeff = 1 / num_users
avgd_wts: OrderedDict[str, Tensor] = OrderedDict()
Expand Down
12 changes: 6 additions & 6 deletions src/main_exp.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import argparse
import subprocess
from typing import List
from typing import List, Any, Dict

from utils.types import ConfigType
from utils.config_utils import process_config
Expand All @@ -19,8 +19,8 @@
post_hoc_plot: bool = True

# for each experiment key, write the modifications to the config file
gpu_ids = [2, 3, 5, 6]
exp_dict = {
gpu_ids: List[int] = [2, 3, 5, 6]
exp_dict: Dict[str, Dict] = {
"experiment_1": {
"algo_config": traditional_fl,
"sys_config": grpc_system_config,
Expand Down Expand Up @@ -54,7 +54,7 @@
help=f"host address of the nodes",
)

args = parser.parse_args()
args: argparse.Namespace = parser.parse_args()

for exp_id, exp_config in exp_dict.items():
# update the algo config with config settings
Expand Down Expand Up @@ -96,8 +96,8 @@

# run the post-hoc analysis
if post_hoc_plot:
full_config = process_config(full_config) # this populates the results path
logs_dir = full_config["results_path"] + '/logs/'
full_config: Dict[str, Any]= process_config(full_config) # this populates the results path
logs_dir:str = full_config["results_path"] + '/logs/'

# aggregate metrics across all users
aggregate_metrics_across_users(logs_dir)
Expand Down