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

Simplify setup #1187

Merged
Show file tree
Hide file tree
Changes from 3 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: 2 additions & 0 deletions openfl-docker/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright 2020-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
19 changes: 1 addition & 18 deletions openfl/component/aggregator/aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from openfl.pipelines import NoCompressionPipeline, TensorCodec
from openfl.protocols import base_pb2, utils
from openfl.utilities import TaskResultKey, TensorKey, change_tags
from openfl.utilities.logs import get_memory_usage, write_metric
from openfl.utilities.logs import get_memory_usage


class Aggregator:
Expand All @@ -38,8 +38,6 @@ class Aggregator:
tensor_db (TensorDB): Object for tensor database.
db_store_rounds* (int): Rounds to store in TensorDB.
logger: Object for logging.
write_logs (bool): Flag to enable log writing.
log_metric_callback: Callback for logging metrics.
best_model_score (optional): Score of the best model. Defaults to
None.
metric_queue (queue.Queue): Queue for metrics.
Expand Down Expand Up @@ -76,9 +74,7 @@ def __init__(
single_col_cert_common_name=None,
compression_pipeline=None,
db_store_rounds=1,
write_logs=False,
log_memory_usage=False,
log_metric_callback=None,
**kwargs,
):
"""Initializes the Aggregator.
Expand All @@ -104,10 +100,6 @@ def __init__(
NoCompressionPipeline.
db_store_rounds (int, optional): Rounds to store in TensorDB.
Defaults to 1.
write_logs (bool, optional): Whether to write logs. Defaults to
False.
log_metric_callback (optional): Callback for log metric. Defaults
to None.
**kwargs: Additional keyword arguments.
"""
self.round_number = 0
Expand Down Expand Up @@ -144,15 +136,6 @@ def __init__(

# Gathered together logging-related objects
self.logger = getLogger(__name__)
self.write_logs = write_logs
self.log_metric_callback = log_metric_callback

if self.write_logs:
self.log_metric = write_metric
if self.log_metric_callback:
self.log_metric = log_metric_callback
self.logger.info("Using custom log metric: %s", self.log_metric)

self.best_model_score = None
self.metric_queue = queue.Queue()

Expand Down
4 changes: 2 additions & 2 deletions openfl/interface/interactive_api/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
from shutil import copytree, ignore_patterns, make_archive
from typing import Dict, Tuple

from tensorboardX import SummaryWriter

from openfl.component.assigner.tasks import Task, TrainTask, ValidateTask
from openfl.federated import Plan
from openfl.interface.aggregation_functions import AggregationFunction, WeightedAverage
Expand Down Expand Up @@ -206,6 +204,8 @@ def stream_metrics(self, tensorboard_logs: bool = True) -> None:
def write_tensorboard_metric(self, metric: dict) -> None:
"""Write metric callback."""
if not self.summary_writer:
from tensorboardX import SummaryWriter

self.summary_writer = SummaryWriter(f"./logs/{self.experiment_name}", flush_secs=5)

self.summary_writer.add_scalar(
Expand Down
2 changes: 2 additions & 0 deletions openfl/plugins/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright 2020-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
2 changes: 2 additions & 0 deletions openfl/plugins/frameworks_adapters/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright 2020-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
2 changes: 2 additions & 0 deletions openfl/plugins/interface_serializer/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright 2020-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
2 changes: 2 additions & 0 deletions openfl/plugins/processing_units_monitor/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright 2020-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
30 changes: 0 additions & 30 deletions openfl/utilities/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,6 @@
import psutil
from rich.console import Console
from rich.logging import RichHandler
from tensorboardX import SummaryWriter

writer = None


def get_writer():
"""Create global writer object.

This function creates a global `SummaryWriter` object for logging to
TensorBoard.
"""
global writer
if not writer:
writer = SummaryWriter("./logs/tensorboard", flush_secs=5)


def write_metric(node_name, task_name, metric_name, metric, round_number):
"""Write metric callback.

This function logs a metric to TensorBoard.

Args:
node_name (str): The name of the node.
task_name (str): The name of the task.
metric_name (str): The name of the metric.
metric (float): The value of the metric.
round_number (int): The current round number.
"""
get_writer()
writer.add_scalar(f"{node_name}/{task_name}/{metric_name}", metric, round_number)


def setup_loggers(log_level=logging.INFO):
Expand Down
133 changes: 20 additions & 113 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# Copyright (C) 2020-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""Setup script."""

"""This package includes dependencies of the openfl project."""

from setuptools import Command
from setuptools import setup
from setuptools import Command, find_packages, setup
from setuptools.command.build_py import build_py
from setuptools.command.develop import develop


class BuildPackageProtos(Command):
Expand Down Expand Up @@ -61,113 +58,34 @@ def run(self):
super().run()


class DevelopGRPC(develop):
"""Command for develop installation."""

def __init__(self, dist):
"""Create a sub-command to execute."""
self.subcommand = BuildPackageProtos(dist)
super().__init__(dist)

def run(self):
"""Build GRPC modules before the default installation."""
self.subcommand.run()
super().run()


with open('README.md', encoding='utf-8') as f:
long_description = f.read()

setup(
name='openfl',
version='1.6',
author='The OpenFL Team',
author='OpenFL Team',
description='Federated Learning for the Edge',
long_description=long_description,
long_description=open("README.md", encoding="utf-8").read(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

long_description_content_type='text/markdown',
url='https://github.com/securefederatedai/openfl',
packages=[
'openfl',
'openfl.component',
'openfl.interface.aggregation_functions',
'openfl.interface.aggregation_functions.core',
'openfl.interface.aggregation_functions.experimental',
'openfl.component.aggregator',
'openfl.component.assigner',
'openfl.component.collaborator',
'openfl.component.director',
'openfl.component.envoy',
'openfl.component.straggler_handling_functions',
'openfl.cryptography',
'openfl.databases',
'openfl.databases.utilities',
'openfl.experimental',
'openfl.experimental.workflow',
'openfl.experimental.workflow.workspace_export',
'openfl.experimental.workflow.federated',
'openfl.experimental.workflow.federated.plan',
'openfl.experimental.workflow.component',
'openfl.experimental.workflow.component.aggregator',
'openfl.experimental.workflow.component.collaborator',
'openfl.experimental.workflow.interface.cli',
'openfl.experimental.workflow.interface',
'openfl.experimental.workflow.placement',
'openfl.experimental.workflow.runtime',
'openfl.experimental.workflow.protocols',
'openfl.experimental.workflow.transport',
'openfl.experimental.workflow.transport.grpc',
'openfl.experimental.workflow.utilities',
'openfl.federated',
'openfl.federated.data',
'openfl.federated.plan',
'openfl.federated.task',
'openfl.interface',
'openfl.interface.interactive_api',
'openfl.native',
'openfl.pipelines',
'openfl.plugins',
'openfl.plugins.frameworks_adapters',
'openfl.plugins.interface_serializer',
'openfl.plugins.processing_units_monitor',
'openfl.protocols',
'openfl.transport',
'openfl.transport.grpc',
'openfl.utilities',
'openfl.utilities.ca',
'openfl.utilities.data_splitters',
'openfl.utilities.fedcurv',
'openfl.utilities.fedcurv.torch',
'openfl.utilities.optimizers.keras',
'openfl.utilities.optimizers.numpy',
'openfl.utilities.optimizers.torch',
'openfl-docker',
'openfl-tutorials',
'openfl-workspace',
],
packages=find_packages(include=("openfl", "openfl.*", "openfl-docker", "openfl-workspace")),
include_package_data=True,
setup_requires=['grpcio-tools>=1.56.2,<1.66.0'], # ensure it is in-sync with `install_requires`
install_requires=[
MasterSkepticista marked this conversation as resolved.
Show resolved Hide resolved
'Click==8.1.7',
'PyYAML>=5.4.1',
'cloudpickle',
'cryptography>=3.4.6',
'docker',
'dynaconf==3.2.6',
'flatten_json',
'grpcio>=1.56.2,<1.66.0',
'ipykernel',
'jupyterlab',
'click',
'psutil',
'pyyaml',
'rich',
'dynaconf',
'tqdm',
'numpy',
'requests',
'cloudpickle',
'cryptography',
'pandas',
'protobuf>=4.22,<6.0.0',
'pyzmq<=26.2.0',
'requests>=2.32.0',
'rich',
'scikit-learn',
'tensorboard',
'tensorboardX>=2.6',
'tqdm',
'flatten_json',
'protobuf>=4.22,<6.0.0',
'grpcio>=1.56.2,<1.66.0',
],
setup_requires=['grpcio-tools>=1.56.2,<1.66.0'],
python_requires='>=3.8, <3.12',
project_urls={
'Bug Tracker': 'https://github.com/securefederatedai/openfl/issues',
Expand All @@ -176,31 +94,20 @@ def run(self):
},
classifiers=[
'Environment :: Console',
# How mature is this project? Common values are
# 3 - Alpha, 4 - Beta, 5 - Production/Stable
'Development Status :: 5 - Production/Stable',
# Indicate who your project is intended for
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'Topic :: Scientific/Engineering :: Artificial Intelligence',
'Topic :: Scientific/Engineering :: Image Recognition',
'Topic :: System :: Distributed Computing',
# Pick your license as you wish
'License :: OSI Approved :: Apache Software License',
# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',

],
entry_points={
'console_scripts': ['fx=openfl.interface.cli:entry']
},
entry_points={'console_scripts': ['fx=openfl.interface.cli:entry']},
cmdclass={
'build_py': BuildPyGRPC,
'build_grpc': BuildPackageProtos,
'develop': DevelopGRPC
},
)
Loading