setup.py 5.19 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
# Copyright 2018, The TensorFlow Federated Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
14
"""TensorFlow Federated is an open-source federated learning framework.
15

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
TensorFlow Federated (TFF) is an open-source framework for machine learning and
other computations on decentralized data. TFF has been developed to facilitate
open research and experimentation with Federated Learning (FL), an approach to
machine learning where a shared global model is trained across many
participating clients that keep their training data locally. For example, FL has
been used to train prediction models for mobile keyboards without uploading
sensitive typing data to servers.

TFF enables developers to use the included federated learning algorithms with
their models and data, as well as to experiment with novel algorithms. The
building blocks provided by TFF can also be used to implement non-learning
computations, such as aggregated analytics over decentralized data.

TFF's interfaces are organized in two layers:

* Federated Learning (FL) API

  The `tff.learning` layer offers a set of high-level interfaces that allow
  developers to apply the included implementations of federated training and
  evaluation to their existing TensorFlow models.

* Federated Core (FC) API

  At the core of the system is a set of lower-level interfaces for concisely
  expressing novel federated algorithms by combining TensorFlow with distributed
  communication operators within a strongly-typed functional programming
  environment. This layer also serves as the foundation upon which we've built
  `tff.learning`.

TFF enables developers to declaratively express federated computations, so they
could be deployed to diverse runtime environments. Included with TFF is a
single-machine simulation runtime for experiments. Please visit the
tutorials and try it out yourself!
49
"""
50
# TODO(b/124800187): Keep in sync with the contents of README.
51

52
import datetime
53
54
55
56
57
58
import sys
import setuptools

DOCLINES = __doc__.split('\n')

REQUIRED_PACKAGES = [
59
60
    'absl-py~=0.9.0',
    'attrs~=19.3.0',
61
    'cachetools~=3.1.1',
62
    'dm-tree~=0.1.1',
63
    'grpcio~=1.29.0',
64
    'h5py~=2.10.0',
65
    'numpy~=1.18.4',
66
    'portpicker~=1.3.1',
67
    'retrying~=1.3.3',
68
    'semantic-version~=2.8.5',
69
    'tensorflow-addons~=0.11.1',
70
    'tensorflow-model-optimization~=0.4.0',
71
    'tensorflow-privacy~=0.5.0',
72
    'tensorflow~=2.3.0',
73
74
]

75
76
77
78
79
with open('tensorflow_federated/version.py') as fp:
  globals_dict = {}
  exec(fp.read(), globals_dict)  # pylint: disable=exec-used
  VERSION = globals_dict['__version__']

Michael Reneer's avatar
Michael Reneer committed
80
81
82
83
84
85
86
87
88
89

def get_package_name(requirement: str) -> str:
  allowed_operators = ['~=', '<', '>', '==', '<=', '>=', '!=']
  separator = allowed_operators[0]
  for operator in allowed_operators[1:]:
    requirement = requirement.replace(operator, separator)
  name, _ = requirement.split(separator, maxsplit=1)
  return name


90
91
if '--nightly' in sys.argv:
  sys.argv.remove('--nightly')
92
  PROJECT_NAME = 'tensorflow_federated_nightly'
93
94
  date = datetime.date.today().strftime('%Y%m%d')
  VERSION = '{}.dev{}'.format(VERSION, date)
95
96
97
98
99
100
101
102
103
  for index, required_package in enumerate(REQUIRED_PACKAGES):
    package_name = get_package_name(required_package)
    if package_name == 'tensorflow':
      REQUIRED_PACKAGES[index] = 'tf-nightly'
    elif package_name == 'tensorflow-addons':
      REQUIRED_PACKAGES[index] = 'tfa-nightly'
else:
  PROJECT_NAME = 'tensorflow_federated'

104
setuptools.setup(
105
    name=PROJECT_NAME,
Michael Reneer's avatar
Michael Reneer committed
106
    version=VERSION,
107
108
109
    packages=setuptools.find_packages(exclude=('tools')),
    description=DOCLINES[0],
    long_description='\n'.join(DOCLINES[2:]),
110
    long_description_content_type='text/plain',
111
112
113
114
115
116
    author='Google Inc.',
    author_email='packages@tensorflow.org',
    url='http://tensorflow.org/federated',
    download_url='https://github.com/tensorflow/federated/tags',
    install_requires=REQUIRED_PACKAGES,
    # PyPI package information.
117
    classifiers=[
118
119
120
121
122
123
124
        'Development Status :: 5 - Production/Stable',
        'Intended Audience :: Developers',
        'Intended Audience :: Education',
        'Intended Audience :: Science/Research',
        'License :: OSI Approved :: Apache Software License',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: 3.6',
125
        'Programming Language :: Python :: 3.7',
126
        'Programming Language :: Python :: 3.8',
127
128
129
130
131
132
        'Topic :: Scientific/Engineering',
        'Topic :: Scientific/Engineering :: Mathematics',
        'Topic :: Scientific/Engineering :: Artificial Intelligence',
        'Topic :: Software Development',
        'Topic :: Software Development :: Libraries',
        'Topic :: Software Development :: Libraries :: Python Modules',
133
    ],
134
135
136
    license='Apache 2.0',
    keywords='tensorflow federated machine learning',
)