forked from deephyper/deephyper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
217 lines (170 loc) · 5.69 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Note: To use the 'upload' functionality of this file, you must:
# $ pip install twine
import os
import platform
import sys
from shutil import rmtree
from setuptools import Command, setup
# path of the directory where this file is located
here = os.path.abspath(os.path.dirname(__file__))
# query platform informations, e.g. 'macOS-12.0.1-arm64-arm-64bit'
platform_infos = platform.platform()
# What packages are required for this module to be executed?
REQUIRED = [
"ConfigSpace>=0.4.20",
"dm-tree",
"Jinja2<3.1",
"numpy>=1.20", # ==1.19.4", # working with 1.20.1
"pandas>=0.24.2",
"packaging",
"parse",
"scikit-learn>=0.23.1",
"scipy>=1.10",
"tqdm>=4.64.0",
"pymoo>=0.6.0",
"pyyaml",
]
# !Requirements for Neural Architecture Search (NAS)
REQUIRED_NAS = ["networkx", "pydot"]
REQUIRED_NAS_PLATFORM = {
"default": ["tensorflow>=2.0.0", "tensorflow_probability"],
"macOS-arm64": ["tensorflow_probability~=0.14"],
}
# if "macOS" in platform_infos and "arm64" in platform_infos:
# REQUIRED_NAS = REQUIRED_NAS + REQUIRED_NAS_PLATFORM["macOS-arm64"]
# else: # x86_64
REQUIRED_NAS = REQUIRED_NAS + REQUIRED_NAS_PLATFORM["default"]
# !Requirements for Pipeline Optimization for ML (popt)
REQUIRED_POPT = ["xgboost"]
# !Requirements for Automated Deep Ensemble with Uncertainty Quantification (AutoDEUQ)
REQUIRED_AUTODEUQ = REQUIRED_NAS + ["ray[default]>=1.3.0"]
# !Transfer Learning for Bayesian Optimization with SVD
REQUIRED_TL_SDV = ["sdv>=0.17.1"]
# What packages are optional?
EXTRAS = {
"autodeuq": REQUIRED_AUTODEUQ, # automated deep ensemble with uncertainty quantification
"automl": ["xgboost"], # for automl with scikit-learn
"jax-cpu": ["jax[cpu]>=0.3.25", "numpyro[cpu]"],
"jax-cuda": ["jax[cuda]>=0.3.25", "numpyro[cuda]"],
"hps": [], # hyperparameter search (already the base requirements)
"nas": REQUIRED_NAS, # neural architecture search
"hps-tl": REQUIRED_TL_SDV, # transfer learning for bayesian optimization,
"mpi": ["mpi4py>=3.1.3"],
"ray": ["ray[default]>=1.3.0"],
"redis": ["redis"],
"redis-hiredis": ["redis[hiredis]"],
"dev": [
# Test
"pytest",
# Packaging
"twine",
# Formatter and Linter
"black==22.6.0",
"flake8==5.0.4",
"pre-commit",
"rstcheck",
# Documentation
"GitPython",
"ipython",
"nbsphinx",
"sphinx>=4,<7",
"sphinx-book-theme==1.0.1",
"pydata-sphinx-theme==0.13.3",
"sphinx-copybutton",
"sphinx-gallery",
"sphinx_lfs_content",
"sphinx-togglebutton",
],
"analytics": [
"altair",
"jupyter",
"jupyter_contrib_nbextensions>=0.5.1",
"nbconvert<6",
"streamlit",
"streamlit-aggrid",
"tinydb",
],
"hvd": ["horovod>=0.21.3", "mpi4py>=3.0.0"],
}
# Default dependencies for DeepHyper
DEFAULT_DEPENDENCIES = REQUIRED[:]
DEFAULT_DEPENDENCIES += EXTRAS["nas"]
DEFAULT_DEPENDENCIES += EXTRAS["autodeuq"]
DEFAULT_DEPENDENCIES += EXTRAS["hps-tl"]
DEFAULT_DEPENDENCIES += EXTRAS["jax-cpu"]
EXTRAS["default"] = DEFAULT_DEPENDENCIES
# Useful commands to build/upload the wheel to PyPI
class UploadCommand(Command):
"""Support setup.py upload."""
description = "Build and publish the package."
user_options = []
@staticmethod
def status(s):
"""Prints things in bold."""
print("\033[1m{0}\033[0m".format(s))
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
try:
self.status("Removing previous builds…")
rmtree(os.path.join(here, "dist"))
except OSError:
pass
self.status("Building Source and Wheel (universal) distribution…")
os.system("{0} setup.py sdist bdist_wheel --universal".format(sys.executable))
self.status("Uploading the package to PyPI via Twine…")
os.system("twine upload dist/*")
sys.exit()
class TestUploadCommand(Command):
"""Support setup.py testupload."""
description = "Build and publish the package to test.pypi."
user_options = []
@staticmethod
def status(s):
"""Prints things in bold."""
print("\033[1m{0}\033[0m".format(s))
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
try:
self.status("Removing previous builds…")
rmtree(os.path.join(here, "dist"))
except OSError:
pass
self.status("Building Source and Wheel (universal) distribution…")
os.system("{0} setup.py sdist bdist_wheel --universal".format(sys.executable))
self.status("Uploading the package to PyPI via Twine…")
os.system("twine upload --repository-url https://test.pypi.org/legacy/ dist/*")
sys.exit()
class TestInstallCommand(Command):
"""Support setup.py testinstall"""
description = "Install deephyper from TestPyPI."
user_options = []
@staticmethod
def status(s):
"""Prints things in bold."""
print("\033[1m{0}\033[0m".format(s))
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
self.status("Downloading the package from Test PyPI and installing it")
os.system("pip install --index-url https://test.pypi.org/simple/ deephyper")
sys.exit()
# Where the magic happens:
setup(
install_requires=REQUIRED,
extras_require=EXTRAS,
cmdclass={
"upload": UploadCommand,
"testupload": TestUploadCommand,
"testinstall": TestInstallCommand,
},
)