Skip to content

Commit

Permalink
Simplify setup (#1187)
Browse files Browse the repository at this point in the history
* Simplify setup.py

Signed-off-by: Shah, Karan <[email protected]>

* Remove tensorboardX and never-used log_metric code

Signed-off-by: Shah, Karan <[email protected]>

* Test reducing requirements

Signed-off-by: Shah, Karan <[email protected]>

* Revert "Remove tensorboardX and never-used log_metric code" and add fn calls

Signed-off-by: Shah, Karan <[email protected]>

* Revert tb removal

Signed-off-by: Shah, Karan <[email protected]>

* Disable tensorboard logging for gramine CI test

Signed-off-by: Shah, Karan <[email protected]>

---------

Signed-off-by: Shah, Karan <[email protected]>
  • Loading branch information
MasterSkepticista authored Dec 4, 2024
1 parent 106b657 commit 60c9195
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 115 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/tr_docker_gramine_direct.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ jobs:
fx workspace create --prefix example_workspace --template keras_cnn_mnist
cd example_workspace
fx plan initialize -a localhost
# Disable tensorboard logging as multiprocessing is not supported in Gramine
# https://github.com/gramineproject/examples/issues/33
sed -i 's/write_logs: true/write_logs: false/g' plan/plan.yaml
fx workspace dockerize --save --revision https://github.com/${GITHUB_REPOSITORY}.git@${{ github.event.pull_request.head.sha }}
- name: Create certificate authority for workspace
Expand Down
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
16 changes: 16 additions & 0 deletions openfl/component/aggregator/aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,14 @@ def send_local_task_results(
}
self.metric_queue.put(metrics)
self.logger.metric("%s", str(metrics))
if self.write_logs:
self.log_metric(
collaborator_name,
task_name,
tensor_key.tensor_name,
float(value),
round_number,
)

task_results.append(tensor_key)

Expand Down Expand Up @@ -938,6 +946,14 @@ def _compute_validation_related_task_metrics(self, task_name):

self.metric_queue.put(metrics)
self.logger.metric("%s", metrics)
if self.write_logs:
self.log_metric(
"aggregator",
task_name,
tensor_key.tensor_name,
float(agg_results),
round_number,
)

# FIXME: Configurable logic for min/max criteria in saving best.
if "validate_agg" in tags:
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
134 changes: 21 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,35 @@ 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(),
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=[
'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',
'tensorboardX',
'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 +95,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
},
)

0 comments on commit 60c9195

Please sign in to comment.