Skip to content

Commit

Permalink
Reformat
Browse files Browse the repository at this point in the history
Signed-off-by: Shah, Karan <[email protected]>
  • Loading branch information
MasterSkepticista committed Dec 2, 2024
1 parent 7215b2d commit b7c6878
Show file tree
Hide file tree
Showing 59 changed files with 76 additions and 18 deletions.
1 change: 1 addition & 0 deletions openfl/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@


"""openfl version information."""

__version__ = "1.6"
1 change: 1 addition & 0 deletions openfl/component/aggregator/aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


"""Aggregator module."""

import queue
import time
from logging import getLogger
Expand Down
1 change: 1 addition & 0 deletions openfl/component/collaborator/collaborator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


"""Collaborator module."""

from enum import Enum
from logging import getLogger
from time import sleep
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


"""Cutoff time based Straggler Handling function."""

import threading
import time
from logging import getLogger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


"""Percentage based Straggler Handling function."""

from logging import getLogger

from openfl.component.straggler_handling_functions.straggler_handling_function import (
Expand Down
1 change: 1 addition & 0 deletions openfl/cryptography/participant.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


"""Cryptography participant utilities."""

from typing import Tuple

from cryptography import x509
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


"""Experimental Aggregator module."""

import inspect
import pickle
import queue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


"""Experimental Collaborator module."""

import pickle
import time
from logging import getLogger
Expand Down
1 change: 1 addition & 0 deletions openfl/experimental/workflow/federated/plan/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


"""Plan module."""

import inspect
import os
from hashlib import sha384
Expand Down
1 change: 1 addition & 0 deletions openfl/experimental/workflow/interface/cli/aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


"""Aggregator module."""

import os
import sys
import threading
Expand Down
1 change: 1 addition & 0 deletions openfl/experimental/workflow/interface/cli/cli_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


"""Module with auxiliary CLI helper functions."""

import os
import re
from itertools import islice
Expand Down
1 change: 1 addition & 0 deletions openfl/experimental/workflow/interface/cli/collaborator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


"""Collaborator module."""

import os
import sys
from glob import glob
Expand Down
1 change: 1 addition & 0 deletions openfl/experimental/workflow/interface/cli/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


"""Plan module."""

import sys
from logging import getLogger
from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions openfl/experimental/workflow/interface/cli/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


"""Workspace module."""

import os
import sys
from hashlib import sha256
Expand Down
4 changes: 2 additions & 2 deletions openfl/experimental/workflow/interface/participants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions openfl/experimental/workflow/protocols/interceptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


"""gRPC interceptors module."""

import collections

import grpc
Expand Down
2 changes: 1 addition & 1 deletion openfl/experimental/workflow/runtime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion openfl/experimental/workflow/runtime/federated_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion openfl/experimental/workflow/runtime/local_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion openfl/experimental/workflow/runtime/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions openfl/experimental/workflow/transport/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@


"""openfl.experimental.workflow.transport package."""

from openfl.experimental.workflow.transport.grpc import AggregatorGRPCClient, AggregatorGRPCServer
4 changes: 1 addition & 3 deletions openfl/experimental/workflow/utilities/metaflow_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion openfl/experimental/workflow/utilities/runtime_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions openfl/experimental/workflow/workspace_export/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


"""Workspace Builder module."""

import ast
import importlib
import inspect
Expand Down
1 change: 1 addition & 0 deletions openfl/federated/data/loader_gandlf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


"""PyTorchDataLoader module."""

from openfl.federated.data.loader import DataLoader


Expand Down
1 change: 1 addition & 0 deletions openfl/federated/plan/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


"""Plan module."""

from hashlib import sha384
from importlib import import_module
from logging import getLogger
Expand Down
3 changes: 2 additions & 1 deletion openfl/federated/task/fl_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: Apache-2.0

"""FederatedModel module."""

import inspect

from openfl.federated.task.runner import TaskRunner
Expand Down Expand Up @@ -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)
]
1 change: 1 addition & 0 deletions openfl/federated/task/runner_keras.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions openfl/federated/task/runner_pt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions openfl/interface/aggregation_functions/core/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


"""Aggregation function interface module."""

from abc import abstractmethod
from typing import Iterator, List, Tuple

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


"""Aggregation function interface module."""

from abc import abstractmethod
from typing import List, Tuple

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


"""FedCurv Aggregation function module."""

import numpy as np

from openfl.interface.aggregation_functions.weighted_average import WeightedAverage
Expand Down
1 change: 1 addition & 0 deletions openfl/interface/aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


"""Aggregator module."""

import sys
from logging import getLogger
from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions openfl/interface/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Copyright (C) 2020-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""CLI module."""

import logging
import os
import re
Expand Down
1 change: 1 addition & 0 deletions openfl/interface/cli_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


"""Module with auxiliary CLI helper functions."""

import os
import re
from itertools import islice
Expand Down
8 changes: 6 additions & 2 deletions openfl/interface/collaborator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


"""Collaborator module."""

import os
import sys
from glob import glob
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions openfl/interface/director.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


"""Director CLI."""

import logging
import shutil
import sys
Expand Down
1 change: 1 addition & 0 deletions openfl/interface/envoy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


"""Envoy CLI."""

import logging
import shutil
import sys
Expand Down
1 change: 1 addition & 0 deletions openfl/interface/experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


"""Experimental CLI."""

from logging import getLogger
from pathlib import Path
from subprocess import check_call
Expand Down
Loading

0 comments on commit b7c6878

Please sign in to comment.