From b7c6878039b8c36151294059187aabd6a1db2db9 Mon Sep 17 00:00:00 2001 From: "Shah, Karan" Date: Mon, 2 Dec 2024 20:37:44 +0530 Subject: [PATCH] Reformat Signed-off-by: Shah, Karan --- openfl/__version__.py | 1 + openfl/component/aggregator/aggregator.py | 1 + openfl/component/collaborator/collaborator.py | 1 + .../cutoff_time_based_straggler_handling.py | 1 + .../percentage_based_straggler_handling.py | 1 + openfl/cryptography/participant.py | 1 + .../workflow/component/aggregator/aggregator.py | 1 + .../workflow/component/collaborator/collaborator.py | 1 + openfl/experimental/workflow/federated/plan/plan.py | 1 + .../experimental/workflow/interface/cli/aggregator.py | 1 + .../experimental/workflow/interface/cli/cli_helper.py | 1 + .../workflow/interface/cli/collaborator.py | 1 + openfl/experimental/workflow/interface/cli/plan.py | 1 + .../experimental/workflow/interface/cli/workspace.py | 1 + .../experimental/workflow/interface/participants.py | 4 ++-- .../experimental/workflow/protocols/interceptors.py | 1 + openfl/experimental/workflow/runtime/__init__.py | 2 +- .../workflow/runtime/federated_runtime.py | 2 +- openfl/experimental/workflow/runtime/local_runtime.py | 3 ++- openfl/experimental/workflow/runtime/runtime.py | 2 +- openfl/experimental/workflow/transport/__init__.py | 1 + .../experimental/workflow/utilities/metaflow_utils.py | 4 +--- .../experimental/workflow/utilities/runtime_utils.py | 2 +- .../experimental/workflow/workspace_export/export.py | 1 + openfl/federated/data/loader_gandlf.py | 1 + openfl/federated/plan/plan.py | 1 + openfl/federated/task/fl_model.py | 3 ++- openfl/federated/task/runner_keras.py | 1 + openfl/federated/task/runner_pt.py | 5 +++-- .../interface/aggregation_functions/core/interface.py | 1 + .../experimental/privileged_aggregation.py | 1 + .../aggregation_functions/fedcurv_weighted_average.py | 1 + openfl/interface/aggregator.py | 1 + openfl/interface/cli.py | 1 + openfl/interface/cli_helper.py | 1 + openfl/interface/collaborator.py | 8 ++++++-- openfl/interface/director.py | 1 + openfl/interface/envoy.py | 1 + openfl/interface/experimental.py | 1 + openfl/interface/interactive_api/experiment.py | 11 ++++++++--- openfl/interface/model.py | 1 + openfl/interface/plan.py | 1 + openfl/interface/tutorial.py | 1 + openfl/interface/workspace.py | 1 + openfl/native/fastestimator.py | 1 + openfl/native/native.py | 1 + openfl/pipelines/stc_pipeline.py | 1 + openfl/plugins/frameworks_adapters/flax_adapter.py | 1 + openfl/plugins/frameworks_adapters/keras_adapter.py | 1 + openfl/plugins/frameworks_adapters/pytorch_adapter.py | 1 + openfl/protocols/interceptors.py | 1 + openfl/utilities/ca.py | 1 + openfl/utilities/ca/ca.py | 1 + openfl/utilities/data_splitters/__init__.py | 1 + openfl/utilities/data_splitters/data_splitter.py | 1 + openfl/utilities/optimizers/keras/fedprox.py | 1 + openfl/utilities/optimizers/numpy/base_optimizer.py | 1 + openfl/utilities/optimizers/torch/__init__.py | 1 + openfl/utilities/workspace.py | 1 + 59 files changed, 76 insertions(+), 18 deletions(-) diff --git a/openfl/__version__.py b/openfl/__version__.py index 713ad49b87..44cb4cc1db 100644 --- a/openfl/__version__.py +++ b/openfl/__version__.py @@ -3,4 +3,5 @@ """openfl version information.""" + __version__ = "1.6" diff --git a/openfl/component/aggregator/aggregator.py b/openfl/component/aggregator/aggregator.py index 805193cf77..3128ef3e89 100644 --- a/openfl/component/aggregator/aggregator.py +++ b/openfl/component/aggregator/aggregator.py @@ -3,6 +3,7 @@ """Aggregator module.""" + import queue import time from logging import getLogger diff --git a/openfl/component/collaborator/collaborator.py b/openfl/component/collaborator/collaborator.py index 3418afab73..b327cd9117 100644 --- a/openfl/component/collaborator/collaborator.py +++ b/openfl/component/collaborator/collaborator.py @@ -3,6 +3,7 @@ """Collaborator module.""" + from enum import Enum from logging import getLogger from time import sleep diff --git a/openfl/component/straggler_handling_functions/cutoff_time_based_straggler_handling.py b/openfl/component/straggler_handling_functions/cutoff_time_based_straggler_handling.py index ca8e218f7c..c3d11ffa4b 100644 --- a/openfl/component/straggler_handling_functions/cutoff_time_based_straggler_handling.py +++ b/openfl/component/straggler_handling_functions/cutoff_time_based_straggler_handling.py @@ -3,6 +3,7 @@ """Cutoff time based Straggler Handling function.""" + import threading import time from logging import getLogger diff --git a/openfl/component/straggler_handling_functions/percentage_based_straggler_handling.py b/openfl/component/straggler_handling_functions/percentage_based_straggler_handling.py index e556ea291b..099ab7e870 100644 --- a/openfl/component/straggler_handling_functions/percentage_based_straggler_handling.py +++ b/openfl/component/straggler_handling_functions/percentage_based_straggler_handling.py @@ -3,6 +3,7 @@ """Percentage based Straggler Handling function.""" + from logging import getLogger from openfl.component.straggler_handling_functions.straggler_handling_function import ( diff --git a/openfl/cryptography/participant.py b/openfl/cryptography/participant.py index 6e18840ff9..f190f68714 100644 --- a/openfl/cryptography/participant.py +++ b/openfl/cryptography/participant.py @@ -3,6 +3,7 @@ """Cryptography participant utilities.""" + from typing import Tuple from cryptography import x509 diff --git a/openfl/experimental/workflow/component/aggregator/aggregator.py b/openfl/experimental/workflow/component/aggregator/aggregator.py index cd15b51570..4e034aa315 100644 --- a/openfl/experimental/workflow/component/aggregator/aggregator.py +++ b/openfl/experimental/workflow/component/aggregator/aggregator.py @@ -3,6 +3,7 @@ """Experimental Aggregator module.""" + import inspect import pickle import queue diff --git a/openfl/experimental/workflow/component/collaborator/collaborator.py b/openfl/experimental/workflow/component/collaborator/collaborator.py index e753180158..a683bbfeb7 100644 --- a/openfl/experimental/workflow/component/collaborator/collaborator.py +++ b/openfl/experimental/workflow/component/collaborator/collaborator.py @@ -3,6 +3,7 @@ """Experimental Collaborator module.""" + import pickle import time from logging import getLogger diff --git a/openfl/experimental/workflow/federated/plan/plan.py b/openfl/experimental/workflow/federated/plan/plan.py index 22f2e2e2cd..6df27d8b1c 100644 --- a/openfl/experimental/workflow/federated/plan/plan.py +++ b/openfl/experimental/workflow/federated/plan/plan.py @@ -3,6 +3,7 @@ """Plan module.""" + import inspect import os from hashlib import sha384 diff --git a/openfl/experimental/workflow/interface/cli/aggregator.py b/openfl/experimental/workflow/interface/cli/aggregator.py index 2af60af020..2c458fa2fe 100644 --- a/openfl/experimental/workflow/interface/cli/aggregator.py +++ b/openfl/experimental/workflow/interface/cli/aggregator.py @@ -3,6 +3,7 @@ """Aggregator module.""" + import os import sys import threading diff --git a/openfl/experimental/workflow/interface/cli/cli_helper.py b/openfl/experimental/workflow/interface/cli/cli_helper.py index d782c3b7e6..e45b3cdd09 100644 --- a/openfl/experimental/workflow/interface/cli/cli_helper.py +++ b/openfl/experimental/workflow/interface/cli/cli_helper.py @@ -3,6 +3,7 @@ """Module with auxiliary CLI helper functions.""" + import os import re from itertools import islice diff --git a/openfl/experimental/workflow/interface/cli/collaborator.py b/openfl/experimental/workflow/interface/cli/collaborator.py index 52f679fa23..fe0cb32940 100644 --- a/openfl/experimental/workflow/interface/cli/collaborator.py +++ b/openfl/experimental/workflow/interface/cli/collaborator.py @@ -3,6 +3,7 @@ """Collaborator module.""" + import os import sys from glob import glob diff --git a/openfl/experimental/workflow/interface/cli/plan.py b/openfl/experimental/workflow/interface/cli/plan.py index 532350aa92..9f40db67de 100644 --- a/openfl/experimental/workflow/interface/cli/plan.py +++ b/openfl/experimental/workflow/interface/cli/plan.py @@ -3,6 +3,7 @@ """Plan module.""" + import sys from logging import getLogger from pathlib import Path diff --git a/openfl/experimental/workflow/interface/cli/workspace.py b/openfl/experimental/workflow/interface/cli/workspace.py index d89d4b239d..1d65d0dde0 100644 --- a/openfl/experimental/workflow/interface/cli/workspace.py +++ b/openfl/experimental/workflow/interface/cli/workspace.py @@ -3,6 +3,7 @@ """Workspace module.""" + import os import sys from hashlib import sha256 diff --git a/openfl/experimental/workflow/interface/participants.py b/openfl/experimental/workflow/interface/participants.py index 618f40161d..5c9c9d594f 100644 --- a/openfl/experimental/workflow/interface/participants.py +++ b/openfl/experimental/workflow/interface/participants.py @@ -123,7 +123,7 @@ def __init__( private_attributes_callable: Callable = None, num_cpus: int = 0, num_gpus: int = 0.0, - **kwargs + **kwargs, ): """Initializes the Collaborator object. @@ -190,7 +190,7 @@ def __init__( private_attributes_callable: Callable = None, num_cpus: int = 0, num_gpus: int = 0.0, - **kwargs + **kwargs, ): """Initializes the Aggregator object. diff --git a/openfl/experimental/workflow/protocols/interceptors.py b/openfl/experimental/workflow/protocols/interceptors.py index 3549529da6..e6a9b57b3f 100644 --- a/openfl/experimental/workflow/protocols/interceptors.py +++ b/openfl/experimental/workflow/protocols/interceptors.py @@ -3,6 +3,7 @@ """gRPC interceptors module.""" + import collections import grpc diff --git a/openfl/experimental/workflow/runtime/__init__.py b/openfl/experimental/workflow/runtime/__init__.py index 991792046e..5d13960b27 100644 --- a/openfl/experimental/workflow/runtime/__init__.py +++ b/openfl/experimental/workflow/runtime/__init__.py @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 -""" openfl.experimental.workflow.runtime package Runtime class.""" +"""openfl.experimental.workflow.runtime package Runtime class.""" from openfl.experimental.workflow.runtime.federated_runtime import FederatedRuntime from openfl.experimental.workflow.runtime.local_runtime import LocalRuntime diff --git a/openfl/experimental/workflow/runtime/federated_runtime.py b/openfl/experimental/workflow/runtime/federated_runtime.py index 885dbe261c..9684fad404 100644 --- a/openfl/experimental/workflow/runtime/federated_runtime.py +++ b/openfl/experimental/workflow/runtime/federated_runtime.py @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 -""" openfl.experimental.workflow.runtime package LocalRuntime class.""" +"""openfl.experimental.workflow.runtime package LocalRuntime class.""" from __future__ import annotations diff --git a/openfl/experimental/workflow/runtime/local_runtime.py b/openfl/experimental/workflow/runtime/local_runtime.py index beb2818e7c..7a7aa3f7a2 100644 --- a/openfl/experimental/workflow/runtime/local_runtime.py +++ b/openfl/experimental/workflow/runtime/local_runtime.py @@ -2,7 +2,8 @@ # SPDX-License-Identifier: Apache-2.0 -""" openfl.experimental.workflow.runtime package LocalRuntime class.""" +"""openfl.experimental.workflow.runtime package LocalRuntime class.""" + from __future__ import annotations import gc diff --git a/openfl/experimental/workflow/runtime/runtime.py b/openfl/experimental/workflow/runtime/runtime.py index 3cffeccafc..317c26ede6 100644 --- a/openfl/experimental/workflow/runtime/runtime.py +++ b/openfl/experimental/workflow/runtime/runtime.py @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 -""" openfl.experimental.workflow.runtime module Runtime class.""" +"""openfl.experimental.workflow.runtime module Runtime class.""" from typing import Callable, List diff --git a/openfl/experimental/workflow/transport/__init__.py b/openfl/experimental/workflow/transport/__init__.py index 83c441b84f..6a8abc0d3f 100644 --- a/openfl/experimental/workflow/transport/__init__.py +++ b/openfl/experimental/workflow/transport/__init__.py @@ -3,4 +3,5 @@ """openfl.experimental.workflow.transport package.""" + from openfl.experimental.workflow.transport.grpc import AggregatorGRPCClient, AggregatorGRPCServer diff --git a/openfl/experimental/workflow/utilities/metaflow_utils.py b/openfl/experimental/workflow/utilities/metaflow_utils.py index 559cbef5b3..ddb08f1905 100644 --- a/openfl/experimental/workflow/utilities/metaflow_utils.py +++ b/openfl/experimental/workflow/utilities/metaflow_utils.py @@ -65,9 +65,7 @@ def __init__(self, name): self.name = name def __enter__(self): - lock_id = hashlib.new( - "sha256", self.name.encode("utf8"), usedforsecurity=False - ).hexdigest() # nosec + lock_id = hashlib.new("sha256", self.name.encode("utf8"), usedforsecurity=False).hexdigest() # nosec # Using SHA-256 to address security warning self.fp = open(f"/tmp/.lock-{lock_id}.lck", "wb") fcntl.flock(self.fp.fileno(), fcntl.LOCK_EX) diff --git a/openfl/experimental/workflow/utilities/runtime_utils.py b/openfl/experimental/workflow/utilities/runtime_utils.py index 193941bc2e..1aba29605a 100644 --- a/openfl/experimental/workflow/utilities/runtime_utils.py +++ b/openfl/experimental/workflow/utilities/runtime_utils.py @@ -176,7 +176,7 @@ def check_resource_allocation(num_gpus, each_participant_gpu_usage): # buffer to cycle though since need_assigned will change sizes as we # assign participants current_dict = need_assigned.copy() - for (participant_name, participant_gpu_usage) in current_dict.items(): + for participant_name, participant_gpu_usage in current_dict.items(): if gpu == 0: break if gpu < participant_gpu_usage: diff --git a/openfl/experimental/workflow/workspace_export/export.py b/openfl/experimental/workflow/workspace_export/export.py index 52e5dab8f9..7df2a7684b 100644 --- a/openfl/experimental/workflow/workspace_export/export.py +++ b/openfl/experimental/workflow/workspace_export/export.py @@ -3,6 +3,7 @@ """Workspace Builder module.""" + import ast import importlib import inspect diff --git a/openfl/federated/data/loader_gandlf.py b/openfl/federated/data/loader_gandlf.py index 648ebe2930..0dda8e3a46 100644 --- a/openfl/federated/data/loader_gandlf.py +++ b/openfl/federated/data/loader_gandlf.py @@ -3,6 +3,7 @@ """PyTorchDataLoader module.""" + from openfl.federated.data.loader import DataLoader diff --git a/openfl/federated/plan/plan.py b/openfl/federated/plan/plan.py index bf9fe1d57a..34c50a4d1e 100644 --- a/openfl/federated/plan/plan.py +++ b/openfl/federated/plan/plan.py @@ -3,6 +3,7 @@ """Plan module.""" + from hashlib import sha384 from importlib import import_module from logging import getLogger diff --git a/openfl/federated/task/fl_model.py b/openfl/federated/task/fl_model.py index 110c91c5bc..70bc537324 100644 --- a/openfl/federated/task/fl_model.py +++ b/openfl/federated/task/fl_model.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 """FederatedModel module.""" + import inspect from openfl.federated.task.runner import TaskRunner @@ -129,7 +130,7 @@ def setup(self, num_collaborators, **kwargs): optimizer=self.lambda_opt, loss_fn=self.loss_fn, data_loader=data_slice, - **kwargs + **kwargs, ) for data_slice in self.data_loader.split(num_collaborators) ] diff --git a/openfl/federated/task/runner_keras.py b/openfl/federated/task/runner_keras.py index df56fd97e1..b33b20fde5 100644 --- a/openfl/federated/task/runner_keras.py +++ b/openfl/federated/task/runner_keras.py @@ -7,6 +7,7 @@ You may copy this file as the starting point of your own keras model. """ + from warnings import catch_warnings, simplefilter import numpy as np diff --git a/openfl/federated/task/runner_pt.py b/openfl/federated/task/runner_pt.py index 2adfe9d5bb..30b56a4120 100644 --- a/openfl/federated/task/runner_pt.py +++ b/openfl/federated/task/runner_pt.py @@ -504,8 +504,9 @@ def validate_(self, validation_dataloader: Iterator[Tuple[np.ndarray, np.ndarray for data, target in validation_dataloader: samples = target.shape[0] total_samples += samples - data, target = torch.tensor(data).to(self.device), torch.tensor(target).to( - self.device, dtype=torch.int64 + data, target = ( + torch.tensor(data).to(self.device), + torch.tensor(target).to(self.device, dtype=torch.int64), ) output = self(data) # get the index of the max log-probability diff --git a/openfl/interface/aggregation_functions/core/interface.py b/openfl/interface/aggregation_functions/core/interface.py index c11fd62621..10f91ace3a 100644 --- a/openfl/interface/aggregation_functions/core/interface.py +++ b/openfl/interface/aggregation_functions/core/interface.py @@ -3,6 +3,7 @@ """Aggregation function interface module.""" + from abc import abstractmethod from typing import Iterator, List, Tuple diff --git a/openfl/interface/aggregation_functions/experimental/privileged_aggregation.py b/openfl/interface/aggregation_functions/experimental/privileged_aggregation.py index 00b8bf7625..0e8beacebc 100644 --- a/openfl/interface/aggregation_functions/experimental/privileged_aggregation.py +++ b/openfl/interface/aggregation_functions/experimental/privileged_aggregation.py @@ -3,6 +3,7 @@ """Aggregation function interface module.""" + from abc import abstractmethod from typing import List, Tuple diff --git a/openfl/interface/aggregation_functions/fedcurv_weighted_average.py b/openfl/interface/aggregation_functions/fedcurv_weighted_average.py index ba87da9c11..7fb0ffe992 100644 --- a/openfl/interface/aggregation_functions/fedcurv_weighted_average.py +++ b/openfl/interface/aggregation_functions/fedcurv_weighted_average.py @@ -3,6 +3,7 @@ """FedCurv Aggregation function module.""" + import numpy as np from openfl.interface.aggregation_functions.weighted_average import WeightedAverage diff --git a/openfl/interface/aggregator.py b/openfl/interface/aggregator.py index 60bd874ee9..80ce56e32e 100644 --- a/openfl/interface/aggregator.py +++ b/openfl/interface/aggregator.py @@ -3,6 +3,7 @@ """Aggregator module.""" + import sys from logging import getLogger from pathlib import Path diff --git a/openfl/interface/cli.py b/openfl/interface/cli.py index e497f47e9e..314cfebf3a 100755 --- a/openfl/interface/cli.py +++ b/openfl/interface/cli.py @@ -2,6 +2,7 @@ # Copyright (C) 2020-2023 Intel Corporation # SPDX-License-Identifier: Apache-2.0 """CLI module.""" + import logging import os import re diff --git a/openfl/interface/cli_helper.py b/openfl/interface/cli_helper.py index cfabe77a0b..065dd43da3 100644 --- a/openfl/interface/cli_helper.py +++ b/openfl/interface/cli_helper.py @@ -3,6 +3,7 @@ """Module with auxiliary CLI helper functions.""" + import os import re from itertools import islice diff --git a/openfl/interface/collaborator.py b/openfl/interface/collaborator.py index 6716fe338c..862ae4db84 100644 --- a/openfl/interface/collaborator.py +++ b/openfl/interface/collaborator.py @@ -3,6 +3,7 @@ """Collaborator module.""" + import os import sys from glob import glob @@ -406,8 +407,10 @@ def certify(collaborator_name, silent, request_pkg=None, import_=False): echo(f"The CSR Hash for file {file_name}.csr is {csr_hash}") if silent: - echo("Signing COLLABORATOR certificate, " - "Warning: manual check of certificate hashes is bypassed in silent mode.") + echo( + "Signing COLLABORATOR certificate, " + "Warning: manual check of certificate hashes is bypassed in silent mode." + ) signed_col_cert = sign_certificate(csr, signing_key, signing_crt.subject) write_crt(signed_col_cert, f"{cert_name}.crt") register_collaborator(CERT_DIR / "client" / f"{file_name}.crt") @@ -455,6 +458,7 @@ def certify(collaborator_name, silent, request_pkg=None, import_=False): else: _import_certificates(import_) + def _import_certificates(archive: str): # Copy the signed certificate and cert chain into PKI_DIR previous_crts = glob(f"{CERT_DIR}/client/*.crt") diff --git a/openfl/interface/director.py b/openfl/interface/director.py index fb1460539e..bd73d865c1 100644 --- a/openfl/interface/director.py +++ b/openfl/interface/director.py @@ -3,6 +3,7 @@ """Director CLI.""" + import logging import shutil import sys diff --git a/openfl/interface/envoy.py b/openfl/interface/envoy.py index 1d99061f40..4e35391bba 100644 --- a/openfl/interface/envoy.py +++ b/openfl/interface/envoy.py @@ -3,6 +3,7 @@ """Envoy CLI.""" + import logging import shutil import sys diff --git a/openfl/interface/experimental.py b/openfl/interface/experimental.py index e2cf08aa78..67c77073fc 100644 --- a/openfl/interface/experimental.py +++ b/openfl/interface/experimental.py @@ -3,6 +3,7 @@ """Experimental CLI.""" + from logging import getLogger from pathlib import Path from subprocess import check_call diff --git a/openfl/interface/interactive_api/experiment.py b/openfl/interface/interactive_api/experiment.py index afaad32938..111c6f1238 100644 --- a/openfl/interface/interactive_api/experiment.py +++ b/openfl/interface/interactive_api/experiment.py @@ -3,6 +3,7 @@ """Python low-level API module.""" + import os import time from collections import defaultdict @@ -396,6 +397,7 @@ def define_task_assigner(self, task_keeper, rounds_to_train): # noqa: C901 "because only validation tasks were given" ) if is_train_task_exist and self.is_validate_task_exist: + def assigner(collaborators, round_number, **kwargs): tasks_by_collaborator = {} for collaborator in collaborators: @@ -405,9 +407,11 @@ def assigner(collaborators, round_number, **kwargs): tasks["aggregated_model_validate"], ] return tasks_by_collaborator + return assigner elif not is_train_task_exist and self.is_validate_task_exist: + def assigner(collaborators, round_number, **kwargs): tasks_by_collaborator = {} for collaborator in collaborators: @@ -415,6 +419,7 @@ def assigner(collaborators, round_number, **kwargs): tasks["aggregated_model_validate"], ] return tasks_by_collaborator + return assigner elif is_train_task_exist and not self.is_validate_task_exist: @@ -566,9 +571,9 @@ def _prepare_plan( # Collaborator part self.plan.config["collaborator"]["settings"]["delta_updates"] = delta_updates self.plan.config["collaborator"]["settings"]["opt_treatment"] = opt_treatment - self.plan.config["collaborator"]["settings"][ - "device_assignment_policy" - ] = device_assignment_policy + self.plan.config["collaborator"]["settings"]["device_assignment_policy"] = ( + device_assignment_policy + ) # DataLoader part for setting, value in data_loader.kwargs.items(): diff --git a/openfl/interface/model.py b/openfl/interface/model.py index 9852124c6d..3703581899 100644 --- a/openfl/interface/model.py +++ b/openfl/interface/model.py @@ -3,6 +3,7 @@ """Model CLI module.""" + from logging import getLogger from pathlib import Path from typing import Union diff --git a/openfl/interface/plan.py b/openfl/interface/plan.py index 04f5dd9da8..93d09c02a5 100644 --- a/openfl/interface/plan.py +++ b/openfl/interface/plan.py @@ -3,6 +3,7 @@ """Plan module.""" + import os import sys from logging import getLogger diff --git a/openfl/interface/tutorial.py b/openfl/interface/tutorial.py index 2c1975f576..e3de9ee7b0 100644 --- a/openfl/interface/tutorial.py +++ b/openfl/interface/tutorial.py @@ -3,6 +3,7 @@ """Tutorial module.""" + from logging import getLogger from os import environ, sep from subprocess import check_call # nosec diff --git a/openfl/interface/workspace.py b/openfl/interface/workspace.py index 567a58f37d..52129a967e 100644 --- a/openfl/interface/workspace.py +++ b/openfl/interface/workspace.py @@ -3,6 +3,7 @@ """Workspace module.""" + import logging import os import shutil diff --git a/openfl/native/fastestimator.py b/openfl/native/fastestimator.py index b99765fabd..a95db185d0 100644 --- a/openfl/native/fastestimator.py +++ b/openfl/native/fastestimator.py @@ -3,6 +3,7 @@ """FederatedFastEstimator module.""" + import os from logging import getLogger from pathlib import Path diff --git a/openfl/native/native.py b/openfl/native/native.py index c9a44cd64f..117058abbb 100644 --- a/openfl/native/native.py +++ b/openfl/native/native.py @@ -7,6 +7,7 @@ This file defines openfl entrypoints to be used directly through python (not CLI) """ + import json import logging import os diff --git a/openfl/pipelines/stc_pipeline.py b/openfl/pipelines/stc_pipeline.py index 61e2fcf704..4a5a9126ce 100644 --- a/openfl/pipelines/stc_pipeline.py +++ b/openfl/pipelines/stc_pipeline.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 """STCPipelinemodule.""" + import copy import gzip as gz diff --git a/openfl/plugins/frameworks_adapters/flax_adapter.py b/openfl/plugins/frameworks_adapters/flax_adapter.py index 332b73a1fc..ce9399d7e8 100644 --- a/openfl/plugins/frameworks_adapters/flax_adapter.py +++ b/openfl/plugins/frameworks_adapters/flax_adapter.py @@ -3,6 +3,7 @@ """Custom model DeviceArray - JAX Numpy adapter.""" + import jax import jax.numpy as jnp import numpy as np diff --git a/openfl/plugins/frameworks_adapters/keras_adapter.py b/openfl/plugins/frameworks_adapters/keras_adapter.py index 971be7840e..a484372ad0 100644 --- a/openfl/plugins/frameworks_adapters/keras_adapter.py +++ b/openfl/plugins/frameworks_adapters/keras_adapter.py @@ -3,6 +3,7 @@ """Keras Framework Adapter plugin.""" + from logging import getLogger from packaging import version diff --git a/openfl/plugins/frameworks_adapters/pytorch_adapter.py b/openfl/plugins/frameworks_adapters/pytorch_adapter.py index a4b33fd73f..60a6db54f4 100644 --- a/openfl/plugins/frameworks_adapters/pytorch_adapter.py +++ b/openfl/plugins/frameworks_adapters/pytorch_adapter.py @@ -3,6 +3,7 @@ """Pytorch Framework Adapter plugin.""" + from copy import deepcopy import numpy as np diff --git a/openfl/protocols/interceptors.py b/openfl/protocols/interceptors.py index 3549529da6..e6a9b57b3f 100644 --- a/openfl/protocols/interceptors.py +++ b/openfl/protocols/interceptors.py @@ -3,6 +3,7 @@ """gRPC interceptors module.""" + import collections import grpc diff --git a/openfl/utilities/ca.py b/openfl/utilities/ca.py index ddedef1016..d522d541cd 100644 --- a/openfl/utilities/ca.py +++ b/openfl/utilities/ca.py @@ -3,6 +3,7 @@ """Generic check functions.""" + import os diff --git a/openfl/utilities/ca/ca.py b/openfl/utilities/ca/ca.py index acf3a50e01..e75d68c491 100644 --- a/openfl/utilities/ca/ca.py +++ b/openfl/utilities/ca/ca.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 """CA module.""" + import base64 import json import os diff --git a/openfl/utilities/data_splitters/__init__.py b/openfl/utilities/data_splitters/__init__.py index 5322f46188..fdf28bb45d 100644 --- a/openfl/utilities/data_splitters/__init__.py +++ b/openfl/utilities/data_splitters/__init__.py @@ -3,6 +3,7 @@ """openfl.utilities.data package.""" + from openfl.utilities.data_splitters.data_splitter import DataSplitter from openfl.utilities.data_splitters.numpy import ( DirichletNumPyDataSplitter, diff --git a/openfl/utilities/data_splitters/data_splitter.py b/openfl/utilities/data_splitters/data_splitter.py index 19333be59a..216607eb3d 100644 --- a/openfl/utilities/data_splitters/data_splitter.py +++ b/openfl/utilities/data_splitters/data_splitter.py @@ -3,6 +3,7 @@ """openfl.utilities.data_splitters.data_splitter module.""" + from abc import ABC, abstractmethod from typing import Iterable, List, TypeVar diff --git a/openfl/utilities/optimizers/keras/fedprox.py b/openfl/utilities/optimizers/keras/fedprox.py index ef1634d77c..2e87648c20 100644 --- a/openfl/utilities/optimizers/keras/fedprox.py +++ b/openfl/utilities/optimizers/keras/fedprox.py @@ -3,6 +3,7 @@ """FedProx Keras optimizer module.""" + import tensorflow as tf import tensorflow.keras as keras from tensorflow.python.ops import standard_ops diff --git a/openfl/utilities/optimizers/numpy/base_optimizer.py b/openfl/utilities/optimizers/numpy/base_optimizer.py index d748727dea..bbbae93ce4 100644 --- a/openfl/utilities/optimizers/numpy/base_optimizer.py +++ b/openfl/utilities/optimizers/numpy/base_optimizer.py @@ -3,6 +3,7 @@ """Base abstract optimizer class module.""" + import abc from importlib import import_module from os.path import splitext diff --git a/openfl/utilities/optimizers/torch/__init__.py b/openfl/utilities/optimizers/torch/__init__.py index 77e989cdd4..7b595b3d7a 100644 --- a/openfl/utilities/optimizers/torch/__init__.py +++ b/openfl/utilities/optimizers/torch/__init__.py @@ -3,6 +3,7 @@ """PyTorch optimizers package.""" + from importlib import util if util.find_spec("torch") is not None: diff --git a/openfl/utilities/workspace.py b/openfl/utilities/workspace.py index e88f431625..e19b03cf16 100644 --- a/openfl/utilities/workspace.py +++ b/openfl/utilities/workspace.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 """Workspace utils module.""" + import logging import os import shutil