Skip to content

Commit

Permalink
ci(*:skip) Format imports in dev, doc, and examples (#3991)
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesbvll authored Aug 11, 2024
1 parent f8298e5 commit c8120f2
Show file tree
Hide file tree
Showing 129 changed files with 287 additions and 408 deletions.
2 changes: 1 addition & 1 deletion dev/build-docker-image-matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"""

import argparse
import json
from dataclasses import asdict, dataclass
from enum import Enum
import json
from typing import Any, Callable, Dict, List, Optional


Expand Down
2 changes: 1 addition & 1 deletion dev/build-example-docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"""Build the Flower Example docs."""

import os
import shutil
import re
import shutil
import subprocess
from pathlib import Path

Expand Down
1 change: 0 additions & 1 deletion dev/check_pr_title.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import sys
import tomllib


if __name__ == "__main__":

pr_title = sys.argv[1]
Expand Down
1 change: 1 addition & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import datetime
import os
import sys

from git import Repo
from sphinx.application import ConfigError

Expand Down
12 changes: 7 additions & 5 deletions examples/advanced-pytorch/client.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import utils
from torch.utils.data import DataLoader
import torch
import flwr as fl
import argparse
from collections import OrderedDict
import warnings
from collections import OrderedDict

import datasets
import flwr as fl
import torch
from torch.utils.data import DataLoader

import utils

warnings.filterwarnings("ignore")

Expand Down
12 changes: 5 additions & 7 deletions examples/advanced-pytorch/server.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
from typing import Dict, Optional, Tuple
from collections import OrderedDict
import argparse
from torch.utils.data import DataLoader
import warnings
from collections import OrderedDict
from typing import Dict, Optional, Tuple

import flwr as fl
import torch
from flwr_datasets import FederatedDataset
from torch.utils.data import DataLoader

import utils

import warnings

from flwr_datasets import FederatedDataset

warnings.filterwarnings("ignore")


Expand Down
7 changes: 3 additions & 4 deletions examples/advanced-pytorch/utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import torch
from torchvision.transforms import Compose, ToTensor, Normalize, Resize, CenterCrop
from torchvision.models import efficientnet_b0, AlexNet
import warnings

import torch
from flwr_datasets import FederatedDataset

from torchvision.models import AlexNet, efficientnet_b0
from torchvision.transforms import CenterCrop, Compose, Normalize, Resize, ToTensor

warnings.filterwarnings("ignore")

Expand Down
4 changes: 1 addition & 3 deletions examples/advanced-tensorflow/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
import os
from pathlib import Path

import tensorflow as tf

import flwr as fl

import tensorflow as tf
from flwr_datasets import FederatedDataset

# Make TensorFlow logs less verbose
Expand Down
3 changes: 1 addition & 2 deletions examples/advanced-tensorflow/server.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from typing import Dict, Optional, Tuple
from pathlib import Path
from typing import Dict, Optional, Tuple

import flwr as fl
import tensorflow as tf

from flwr_datasets import FederatedDataset


Expand Down
5 changes: 2 additions & 3 deletions examples/android/tflite_convertor/convert_to_tflite.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import tensorflow as tf
from tensorflow.keras import layers
from tensorflow.keras.regularizers import l2
from tfltransfer import bases
from tfltransfer import heads
from tfltransfer import optimizers

from tfltransfer import bases, heads, optimizers
from tfltransfer.tflite_transfer_converter import TFLiteTransferConverter

# Define the base model.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
"""Base model configuration for MobileNetV2."""


from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import absolute_import, division, print_function

import tensorflow as tf

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
"""Base model abstract base class that handles quantization."""


from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import absolute_import, division, print_function

import abc

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
"""Base model configuration that reads a specified SavedModel."""


from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import absolute_import, division, print_function

import tensorflow as tf

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
"""Head model configuration for Keras models."""


from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import absolute_import, division, print_function

import os
import shutil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
"""Head model configuration for classifier SavedModels."""


from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import absolute_import, division, print_function

import os
import shutil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
"""Head model configuration for simple softmax classifiers."""


from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import absolute_import, division, print_function

import numpy as np
import tensorflow as tf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
"""End-to-end tests that check model correctness."""


from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import absolute_import, division, print_function

import os
import tempfile
Expand All @@ -27,10 +25,7 @@
from tensorflow.compat import v1 as tfv1

# pylint: disable=g-bad-import-order
from tfltransfer import bases
from tfltransfer import optimizers
from tfltransfer import heads
from tfltransfer import tflite_transfer_converter
from tfltransfer import bases, heads, optimizers, tflite_transfer_converter

# pylint: enable=g-bad-import-order

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
"""Adam optimizer implementation for transfer learning models."""


from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import absolute_import, division, print_function

import tensorflow as tf
import tensorflow.compat.v1 as tfv1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
"""SGD optimizer implementation for transfer learning models."""


from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import absolute_import, division, print_function

import tensorflow as tf
import tensorflow.compat.v1 as tfv1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,12 @@
"""


from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import absolute_import, division, print_function

import argparse

# pylint: disable=g-bad-import-order
from tfltransfer import bases
from tfltransfer import heads
from tfltransfer import optimizers
from tfltransfer import tflite_transfer_converter
from tfltransfer import bases, heads, optimizers, tflite_transfer_converter

# pylint: enable=g-bad-import-order

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
"""


from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import absolute_import, division, print_function

import os

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
"""Tests for tflite_transfer_converter."""


from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import absolute_import, division, print_function

import tempfile
import unittest
Expand All @@ -27,10 +25,7 @@
from tensorflow.keras.regularizers import l2

# pylint: disable=g-bad-import-order
from tfltransfer import bases
from tfltransfer import heads
from tfltransfer import optimizers
from tfltransfer import tflite_transfer_converter
from tfltransfer import bases, heads, optimizers, tflite_transfer_converter

# pylint: enable=g-bad-import-order

Expand Down
4 changes: 1 addition & 3 deletions examples/android/tflite_convertor/tfltransfer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
"""Helper utilities for various parts of the converter."""


from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import absolute_import, division, print_function

from tensorflow.compat import v1 as tfv1

Expand Down
11 changes: 1 addition & 10 deletions examples/app-pytorch/client.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
from flwr.client import ClientApp, NumPyClient

from task import (
Net,
DEVICE,
load_data,
get_weights,
set_weights,
train,
test,
)

from task import DEVICE, Net, get_weights, load_data, set_weights, test, train

# Load model and data (simple CNN, CIFAR-10)
net = Net().to(DEVICE)
Expand Down
2 changes: 1 addition & 1 deletion examples/app-pytorch/client_low_level.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from flwr.client import ClientApp
from flwr.common import Message, Context
from flwr.common import Context, Message


def hello_world_mod(msg, ctx, call_next) -> Message:
Expand Down
2 changes: 1 addition & 1 deletion examples/app-pytorch/server.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import List, Tuple

from flwr.common import Metrics, ndarrays_to_parameters
from flwr.server import ServerApp, ServerConfig
from flwr.server.strategy import FedAvg
from flwr.common import Metrics, ndarrays_to_parameters

from task import Net, get_weights

Expand Down
12 changes: 6 additions & 6 deletions examples/app-pytorch/server_custom.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
from typing import List, Tuple, Dict
import random
import time
from typing import Dict, List, Tuple

import flwr as fl
from flwr.common import (
DEFAULT_TTL,
Code,
Context,
FitIns,
ndarrays_to_parameters,
parameters_to_ndarrays,
NDArrays,
Code,
Message,
MessageType,
Metrics,
DEFAULT_TTL,
NDArrays,
ndarrays_to_parameters,
parameters_to_ndarrays,
)
from flwr.common.recordset_compat import fitins_to_recordset, recordset_to_fitres
from flwr.server import Driver, History
Expand Down
7 changes: 3 additions & 4 deletions examples/app-pytorch/server_low_level.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
from typing import List, Tuple, Dict
import random
import time
from typing import Dict, List, Tuple

import flwr as fl
from flwr.common import (
DEFAULT_TTL,
Context,
NDArrays,
Message,
MessageType,
Metrics,
NDArrays,
RecordSet,
DEFAULT_TTL,
)
from flwr.server import Driver


# Run via `flower-server-app server:app`
app = fl.server.ServerApp()

Expand Down
Loading

0 comments on commit c8120f2

Please sign in to comment.