Skip to content

Commit

Permalink
Update black and isort (#2995)
Browse files Browse the repository at this point in the history
* Update black and isort

* ran format.sh in baslines/flwr_baselines

* niid_bench format

* formatting new baselines

* format fedbn

---------

Co-authored-by: jafermarq <[email protected]>
  • Loading branch information
danieljanes and jafermarq authored Feb 22, 2024
1 parent a1a6b9e commit 26da94b
Show file tree
Hide file tree
Showing 154 changed files with 213 additions and 168 deletions.
4 changes: 2 additions & 2 deletions baselines/baseline_template/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ flwr = { extras = ["simulation"], version = "1.5.0" }
hydra-core = "1.3.2" # don't change this

[tool.poetry.dev-dependencies]
isort = "==5.11.5"
black = "==23.1.0"
isort = "==5.13.2"
black = "==24.2.0"
docformatter = "==1.5.1"
mypy = "==1.4.1"
pylint = "==2.8.2"
Expand Down
4 changes: 2 additions & 2 deletions baselines/dasha/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ torchvision = [{ url = "https://download.pytorch.org/whl/cu118/torchvision-0.15.
{ url = "https://download.pytorch.org/whl/cpu/torchvision-0.15.0-cp39-cp39-macosx_11_0_arm64.whl", markers="sys_platform == 'darwin'"}]

[tool.poetry.dev-dependencies]
isort = "==5.11.5"
black = "==23.1.0"
isort = "==5.13.2"
black = "==24.2.0"
docformatter = "==1.5.1"
mypy = "==1.4.1"
pylint = "==2.8.2"
Expand Down
1 change: 0 additions & 1 deletion baselines/depthfl/depthfl/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""ResNet18 model architecutre, training, and testing functions for CIFAR100."""


from typing import List, Tuple

import torch
Expand Down
4 changes: 2 additions & 2 deletions baselines/depthfl/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ torch = { url = "https://download.pytorch.org/whl/cu116/torch-1.13.1%2Bcu116-cp3
torchvision = { url = "https://download.pytorch.org/whl/cu116/torchvision-0.14.1%2Bcu116-cp310-cp310-linux_x86_64.whl" }

[tool.poetry.dev-dependencies]
isort = "==5.11.5"
black = "==23.1.0"
isort = "==5.13.2"
black = "==24.2.0"
docformatter = "==1.5.1"
mypy = "==1.4.1"
pylint = "==2.8.2"
Expand Down
4 changes: 2 additions & 2 deletions baselines/fedavgm/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ numpy = "1.25.2"
matplotlib = "^3.7.2"

[tool.poetry.dev-dependencies]
isort = "==5.11.5"
black = "==23.1.0"
isort = "==5.13.2"
black = "==24.2.0"
docformatter = "==1.5.1"
mypy = "==1.4.1"
pylint = "==2.8.2"
Expand Down
1 change: 1 addition & 0 deletions baselines/fedbn/fedbn/dataset.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Digits dataset."""

import os
from random import shuffle
from typing import List, Optional, Tuple
Expand Down
1 change: 1 addition & 0 deletions baselines/fedbn/fedbn/strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Needed only when the strategy is not yet implemented in Flower or because you want to
extend or modify the functionality of an existing strategy.
"""

from typing import Dict, List, Tuple

from flwr.common.typing import Metrics
Expand Down
4 changes: 2 additions & 2 deletions baselines/fedbn/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ torchvision = { url = "https://download.pytorch.org/whl/cu117/torchvision-0.15.2
tqdm = "^4.66.1"

[tool.poetry.dev-dependencies]
isort = "==5.11.5"
black = "==23.1.0"
isort = "==5.13.2"
black = "==24.2.0"
docformatter = "==1.5.1"
mypy = "==1.4.1"
pylint = "==2.8.2"
Expand Down
1 change: 1 addition & 0 deletions baselines/fedmeta/fedmeta/dataset_preparation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
uncomment the lines below and tell us in the README.md (see the "Running the Experiment"
block) that this file should be executed first.
"""

import json
import os
from collections import defaultdict
Expand Down
1 change: 0 additions & 1 deletion baselines/fedmeta/fedmeta/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
model is going to be evaluated, etc. At the end, this script saves the results.
"""


import flwr as fl
import hydra
from hydra.core.hydra_config import HydraConfig
Expand Down
1 change: 1 addition & 0 deletions baselines/fedmeta/fedmeta/strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Needed only when the strategy is not yet implemented in Flower or because you want to
extend or modify the functionality of an existing strategy.
"""

from collections import OrderedDict
from logging import WARNING
from typing import Dict, List, Optional, Tuple, Union
Expand Down
4 changes: 2 additions & 2 deletions baselines/fedmeta/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ torchvision = { url = "https://download.pytorch.org/whl/cu117/torchvision-0.15.2
pillow = "9.5.0" # needed <10.0.0 for LEAF repo scripts

[tool.poetry.dev-dependencies]
isort = "==5.11.5"
black = "==23.1.0"
isort = "==5.13.2"
black = "==24.2.0"
docformatter = "==1.5.1"
mypy = "==1.4.1"
pylint = "==2.8.2"
Expand Down
1 change: 1 addition & 0 deletions baselines/fedmlb/fedmlb/dataset.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Handle dataset loading and preprocessing utility."""

import os
from typing import Union

Expand Down
4 changes: 2 additions & 2 deletions baselines/fedmlb/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ matplotlib = "3.7.1"
psutil = "5.9.5" # this is just to log some info about memory usage

[tool.poetry.dev-dependencies]
isort = "==5.11.5"
black = "==23.1.0"
isort = "==5.13.2"
black = "==24.2.0"
docformatter = "==1.5.1"
mypy = "==1.4.1"
pylint = "==2.8.2"
Expand Down
1 change: 0 additions & 1 deletion baselines/fednova/fednova/dataset_preparation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
obtained from source: https://github.com/JYWa/FedNova/blob/master/util_v4.py
"""


from random import Random

import numpy as np
Expand Down
1 change: 0 additions & 1 deletion baselines/fednova/fednova/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Utility functions for FedNova such as computing accuracy, plotting results, etc."""


import glob
import os
from typing import List, Tuple
Expand Down
4 changes: 2 additions & 2 deletions baselines/fednova/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ matplotlib = "3.5.3"
pandas = "1.3.5"

[tool.poetry.dev-dependencies]
isort = "==5.11.5"
black = "==23.1.0"
isort = "==5.13.2"
black = "==24.2.0"
docformatter = "==1.5.1"
mypy = "==1.4.1"
pylint = "==2.8.2"
Expand Down
4 changes: 1 addition & 3 deletions baselines/fedpara/fedpara/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,7 @@ def _calc_from_ratio(self):
# r3 is floored because we cannot take the ceil as it results a bigger number
# of parameters than the original problem

num_target_params = (
self.out_channels * self.in_channels * (self.kernel_size**2)
)
num_target_params = self.out_channels * self.in_channels * (self.kernel_size**2)
a, b, c = (
self.kernel_size**2,
self.out_channels + self.in_channels,
Expand Down
4 changes: 2 additions & 2 deletions baselines/fedpara/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ torch = { url = "https://download.pytorch.org/whl/cu117/torch-2.0.1%2Bcu117-cp31
torchvision = { url = "https://download.pytorch.org/whl/cu117/torchvision-0.15.2%2Bcu117-cp310-cp310-linux_x86_64.whl" }

[tool.poetry.dev-dependencies]
isort = "==5.11.5"
black = "==23.1.0"
isort = "==5.13.2"
black = "==24.2.0"
docformatter = "==1.5.1"
mypy = "==1.4.1"
pylint = "==2.8.2"
Expand Down
7 changes: 4 additions & 3 deletions baselines/fedper/fedper/client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Client implementation - can call FedPer and FedAvg clients."""

import pickle
from collections import OrderedDict, defaultdict
from pathlib import Path
Expand Down Expand Up @@ -322,9 +323,9 @@ def client_fn(cid: str) -> BaseClient:
# Create the test loader
testloader = DataLoader(testset, config.batch_size)

manager: Union[
Type[MobileNetModelManager], Type[ResNetModelManager]
] = MobileNetModelManager
manager: Union[Type[MobileNetModelManager], Type[ResNetModelManager]] = (
MobileNetModelManager
)
if config.model_name.lower() == "resnet":
manager = ResNetModelManager
elif config.model_name.lower() == "mobile":
Expand Down
1 change: 1 addition & 0 deletions baselines/fedper/fedper/constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Constants used in machine learning pipeline."""

from enum import Enum


Expand Down
1 change: 1 addition & 0 deletions baselines/fedper/fedper/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
`dataset_preparation.py` module. You can use all those functions from functions/methods
defined here of course.
"""

import os
import pickle
import sys
Expand Down
1 change: 1 addition & 0 deletions baselines/fedper/fedper/dataset_preparation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Dataset preparation."""

import os
import random
from collections import Counter
Expand Down
1 change: 1 addition & 0 deletions baselines/fedper/fedper/implemented_models/mobile_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""MobileNet-v1 model, model manager and model split."""

from typing import Dict, List, Optional, Tuple, Union

import torch
Expand Down
1 change: 1 addition & 0 deletions baselines/fedper/fedper/implemented_models/resnet_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""ResNet model, model manager and split."""

from typing import Dict, List, Optional, Tuple, Union

import torch
Expand Down
1 change: 1 addition & 0 deletions baselines/fedper/fedper/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Abstract class for splitting a model into body and head."""

from abc import ABC, abstractmethod
from collections import OrderedDict
from typing import Any, Dict, List, Tuple, Type, Union
Expand Down
1 change: 1 addition & 0 deletions baselines/fedper/fedper/server.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Server strategies pipelines for FedPer."""

from flwr.server.strategy.fedavg import FedAvg

from fedper.strategy import (
Expand Down
1 change: 1 addition & 0 deletions baselines/fedper/fedper/strategy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""FL server strategies."""

from collections import OrderedDict
from pathlib import Path
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
Expand Down
7 changes: 4 additions & 3 deletions baselines/fedper/fedper/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utility functions for FedPer."""

import os
import pickle
import time
Expand Down Expand Up @@ -97,9 +98,9 @@ def get_create_model_fn(
]:
"""Get create model function."""
device = config.server_device
split: Union[
Type[MobileNetModelSplit], Type[ResNetModelSplit]
] = MobileNetModelSplit
split: Union[Type[MobileNetModelSplit], Type[ResNetModelSplit]] = (
MobileNetModelSplit
)
if config.model_name.lower() == "mobile":

def create_model() -> Union[Type[MobileNet], Type[ResNet]]:
Expand Down
4 changes: 2 additions & 2 deletions baselines/fedper/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ torch = { url = "https://download.pytorch.org/whl/cu117/torch-2.0.1%2Bcu117-cp31
torchvision = { url = "https://download.pytorch.org/whl/cu117/torchvision-0.15.2%2Bcu117-cp310-cp310-linux_x86_64.whl" }

[tool.poetry.dev-dependencies]
isort = "==5.11.5"
black = "==23.1.0"
isort = "==5.13.2"
black = "==24.2.0"
docformatter = "==1.5.1"
mypy = "==1.4.1"
pylint = "==2.8.2"
Expand Down
1 change: 0 additions & 1 deletion baselines/fedprox/fedprox/client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Defines the MNIST Flower Client and a function to instantiate it."""


from collections import OrderedDict
from typing import Callable, Dict, List, Tuple

Expand Down
1 change: 0 additions & 1 deletion baselines/fedprox/fedprox/dataset.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""MNIST dataset utilities for federated learning."""


from typing import Optional, Tuple

import torch
Expand Down
1 change: 1 addition & 0 deletions baselines/fedprox/fedprox/dataset_preparation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Functions for dataset download and processing."""

from typing import List, Optional, Tuple

import numpy as np
Expand Down
1 change: 0 additions & 1 deletion baselines/fedprox/fedprox/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""CNN model architecture, training, and testing functions for MNIST."""


from typing import List, Tuple

import torch
Expand Down
1 change: 0 additions & 1 deletion baselines/fedprox/fedprox/server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Flower Server."""


from collections import OrderedDict
from typing import Callable, Dict, Optional, Tuple

Expand Down
1 change: 0 additions & 1 deletion baselines/fedprox/fedprox/strategy.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Flower strategy."""


from typing import List, Tuple, Union

from flwr.common import Metrics
Expand Down
4 changes: 2 additions & 2 deletions baselines/fedprox/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ torch = { url = "https://download.pytorch.org/whl/cu117/torch-2.0.1%2Bcu117-cp31
torchvision = { url = "https://download.pytorch.org/whl/cu117/torchvision-0.15.2%2Bcu117-cp310-cp310-linux_x86_64.whl" }

[tool.poetry.dev-dependencies]
isort = "==5.11.5"
black = "==23.1.0"
isort = "==5.13.2"
black = "==24.2.0"
docformatter = "==1.5.1"
mypy = "==1.4.1"
pylint = "==2.8.2"
Expand Down
1 change: 1 addition & 0 deletions baselines/fedstar/fedstar/client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Required imports for client.py script."""

import gc
import logging
import os
Expand Down
1 change: 1 addition & 0 deletions baselines/fedstar/fedstar/clients.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Required imports for clients.py script."""

import multiprocessing
import os
import sys
Expand Down
1 change: 1 addition & 0 deletions baselines/fedstar/fedstar/dataset.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Required imports for data.py script."""

import os

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions baselines/fedstar/fedstar/dataset_preparation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Generate 1-second audio clip from background sounds in speechcommands."""

import os
import random

Expand Down
1 change: 1 addition & 0 deletions baselines/fedstar/fedstar/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Required imports for data.py script."""

import itertools
import time

Expand Down
1 change: 1 addition & 0 deletions baselines/fedstar/fedstar/server.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Required imports for server.py script."""

import gc
import logging
import os
Expand Down
Loading

0 comments on commit 26da94b

Please sign in to comment.