Skip to content

Commit bab028c

Browse files
committed
Moving from Niels repo
1 parent 7f08350 commit bab028c

File tree

93 files changed

+9230
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+9230
-0
lines changed

MANIFEST.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
include deep_cave/util/logging.yml
2+
3+
include deep_cave/_version.py
4+
include versioneer.py
5+
6+
include setup.cfg
7+
include setup.py
8+
9+
include tox.ini
10+
11+
include MANIFEST.in
12+
include README.md

Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = docs
9+
BUILDDIR = build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

Pipfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[[source]]
2+
name = "pypi"
3+
url = "https://pypi.org/simple"
4+
verify_ssl = true
5+
6+
[dev-packages]
7+
pytest = ">=6.2.1"
8+
more-itertools = ">=8.5.0"
9+
tqdm = ">=4.56.0"
10+
pipenv-setup = ">=3.1.1"
11+
tox = ">=3.21.0"
12+
coverage = ">=5.3.1"
13+
pytest-cov = ">=2.10.1"
14+
sphinx = ">=3.4.3"
15+
recommonmark = ">=0.7.1"
16+
versioneer = ">=0.19"
17+
skl2onnx = ">=1.7.0"
18+
scikit-optimize = ">=0.8.1"
19+
20+
[packages]
21+
pandas = ">=1.2.0"
22+
numpy = ">=1.19.0"
23+
matplotlib = ">=3.3.3"
24+
dash = ">=1.18.1"
25+
PyYAML = ">=5.3.1"
26+
scipy = ">=1.6"
27+
dash-dangerously-set-inner-html = ">=0.0.2"
28+
onnxruntime = ">=1.6.0"
29+
configspace = ">=0.4.17"
30+
pdpbox = ">=0.2.1"
31+
fanova = {editable = true,git = "https://github.com/automl/fanova.git@2442ef36856a98f8755089f915ffe8373d9b5046"}
32+
pyimp = ">=1.1.2"
33+
dash-bootstrap-components = ">=0.11.1"
34+
scikit-learn = ">=0.24"
35+
36+
[requires]
37+
python_version = "3.8"

Pipfile.lock

Lines changed: 1645 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 270 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,270 @@
1+
# DeepCAVE
2+
3+
# Quickstart;
4+
5+
```shell
6+
# clone with submodules
7+
git clone --recurse-submodules [email protected]:Nielsmitie/DeepCAVE.git
8+
# install dependencies
9+
pipenv install --dev
10+
# enter pipenv shell
11+
pipenv shell
12+
# for non IDE user add deep_cave to PYTHONPATH otherwise set deep_cave as source
13+
export PYTHONPATH=[path/to/DeepCAVE]
14+
15+
# generate some testing data by running the test scripts
16+
python tests/api_tests/api_test.py
17+
# set the environmental variable for the server
18+
export STUDIES_LOCATION='tests/studies'
19+
# start the server
20+
python deep_cave/server/__init__.py
21+
# visit the displayed website and select the signle experiment and start
22+
# experimenting
23+
```
24+
25+
Additional information is displayed below.
26+
27+
### Setup
28+
29+
#### Cloning with submodules
30+
Clone the project. (LCBench doesn't have a setup.py
31+
so install it as a git submodule)
32+
```shell script
33+
git clone --recurse-submodules [email protected]:Nielsmitie/DeepCAVE.git
34+
```
35+
36+
#### Install dependencies
37+
38+
To manage dependencies this project uses pipenv.
39+
The first order requirements are listed human-readable in
40+
Pipefile. The locked versions and sub-dependencies are in Pipefile.lock.
41+
42+
Install dependencies
43+
```shell script
44+
pipenv install --dev
45+
```
46+
47+
if pyrfr fails for fanova, then you might need to install swig 3 or install
48+
the correct swig version.
49+
```shell
50+
sudo apt-get remove swig
51+
sudo apt install swig3.0
52+
sudo ln -s /usr/bin/swig3.0 /usr/bin/swig
53+
pipenv shell
54+
pip uninstall pyrfr
55+
pip install pyrfr --no-cache
56+
```
57+
58+
### Data preparation for testing
59+
Download data from [LCBench](https://figshare.com/projects/LCBench/74151),
60+
unpack and move them to the data dir.
61+
To run the tests download "six_datasets_lw.zip", unpack it and
62+
move it into the `test/data` directory.
63+
64+
### Usage
65+
66+
#### Generate Data
67+
68+
To generate data from a hyperband run with the "Fashion-MNIST" dataset
69+
run tests/api_tests/lcbench_test.py or tests/api_tests/api_test.py or
70+
tests/api_tests/log_model_test.py.
71+
72+
To generate multi-fidelity random data run api_test.py.
73+
74+
#### Visualization
75+
76+
Run
77+
```
78+
deep_cave.server.__init__.py
79+
```
80+
81+
with the set environment variables:
82+
- `STUDIES_LOCATION`: Set to the location of the saved study files. (If you are
83+
following the tutorial above this should be `../../tests/studies`)
84+
- `MODELS_LOCATION`: Set to location of the saved model files
85+
(maybe `../../tests/models`) ()
86+
- `CONVERTER`: If you want a converter instead of the default backend.
87+
(not need for this tutorial, but when you want to import data from a
88+
non DeepCAVE source)
89+
90+
Set the environment variables either via console
91+
```
92+
export MODELS_LOCATION="../../tests/studies"
93+
```
94+
or via IDE or via pipenv, by including a .env file inside the project.
95+
96+
Another way would be to modify the deep_cave/server/config.py directly.
97+
98+
### Extending
99+
100+
#### Analysis Plugins
101+
102+
To customize the analysis, create a new file with a class that inherits from
103+
deep_cave.server.plugins.plugin.Plugin. Implement all necessary methods and
104+
properties.
105+
106+
Include the plugin into the server by setting the environment variable
107+
`EXTERNAL_PLUGIN_LOCATIONS` with a string value of comma separated absolute paths
108+
to your plugin dir. Use wildcards to import more than one class per path.
109+
110+
E.g.
111+
```
112+
export EXTERNAL_PLUGIN_LOCATIONS='/home/[user]/projects/plugins/*'
113+
```
114+
115+
The plugin will be loaded on start up and checked.
116+
The plugin will be available in the UI.
117+
118+
##### Converts
119+
120+
The internal representation of data is abstracted away from the physical
121+
location and format. A converter can be used to load data in an
122+
arbitrary format or save it in any format.
123+
124+
To make this customization as easy as possible it is possible to load
125+
converters from the local filesystem directly into the project, without
126+
modifying it directly.
127+
128+
In order to use this feature, specify an environment variable called
129+
`EXTERNAL_CONVERTER_LOCATIONS` and specify a directory with wildcards
130+
131+
```
132+
export EXTERNAL_CONVERTER_LOCATIONS='/home/[user]/projects/converters/*'
133+
```
134+
135+
### Packaging
136+
137+
#### Pipfile
138+
139+
The pipfile contains the requirements with specified versions.
140+
This is necessary so that when this code is packaged there aren't
141+
any problems with the client code.
142+
143+
Pipfile.lock contains the specified dependency versions.
144+
145+
#### Setup.py
146+
147+
Contains all information needed for packaging this code.
148+
149+
Add the dependencies to setup.py via:
150+
```shell script
151+
pipenv run pipenv-setup sync --pipfile --dev
152+
```
153+
Again, only sync the general requirements to avoid conflict
154+
when installing this package.
155+
156+
157+
#### MANIFEST.in
158+
159+
Include the files, like logging.yml that also need to be packaged.
160+
161+
162+
### Testing
163+
164+
#### Pytest
165+
166+
All tests are run with pytest.
167+
```shell script
168+
pipenv run pytest
169+
```
170+
All tests are inside the tests directory. Each file with the suffix
171+
\_test.py is a test. In each file the functions with the prefix test\_
172+
are run by the pytest command
173+
174+
#### Tox
175+
176+
For test automation tox is used.
177+
178+
- It creates an environment with a specified python version
179+
- It packages the project according to setup.py
180+
- It runs all the tests on the created package
181+
- It generates the docs
182+
- It updates the dependencies inside setup.py
183+
184+
#### CI
185+
186+
Tox can then be used inside a CI system to run automated testing.
187+
188+
MISSING: Download the necessary data for testing.
189+
190+
### Documentation
191+
192+
Use [Numpy](https://numpydoc.readthedocs.io/en/latest/format.html)/Pandas
193+
style doc-strings on code.
194+
195+
In `docs` the .rst files are used to generate documentation for
196+
this project. The resulting website can be found in `build`.
197+
198+
Regenerate docs/modules
199+
```shell
200+
sphinx-apidoc -o docs/deep_cave deep_cave
201+
```
202+
Building docs will be automatically done when running tox.
203+
Otherwise run
204+
```
205+
pipenv run python setup.py build_sphinx
206+
```
207+
208+
View the docs under DeepCAVE/build/index.html (open in Browser).
209+
Currently everything is documented in Code an no additional
210+
doc pages were created.
211+
212+
213+
# How it should work in the future
214+
215+
## Install
216+
217+
Install from repo, when publicly avaialble
218+
```shell script
219+
pip install -e https://github.com/Nielsmitie/DeepCAVE
220+
```
221+
Another way to install is documented in the `setup` section.
222+
223+
Alternative, clone repo and install it locally
224+
```shell script
225+
git clone https://github.com/Nielsmitie/DeepCAVE
226+
cd DeepCAVE
227+
pip install -e .
228+
```
229+
230+
When a package is uploaded to pypi
231+
```shell
232+
pip install deepcave
233+
```
234+
235+
236+
## Usage
237+
238+
### Logging
239+
Start a project with deep_cave installed.
240+
241+
```python
242+
import deep_cave
243+
244+
config = {'lr': 1e-8}
245+
fidelity = 2
246+
247+
with deep_cave.start_trial(config, fidelity) as trial:
248+
trial.log_metric(.05)
249+
```
250+
251+
Set location for the saved file via deep_cave.set_tracking_uri.
252+
253+
### Visualization
254+
255+
To start the server run
256+
```shell script
257+
deep_cave server
258+
# or
259+
pipenv run python deep_cave/server/__init__.py
260+
```
261+
with the correct environment variables set.
262+
263+
264+
### Download Chrome Driver (for UI testing) (Deprecated)
265+
266+
Download the [chrome driver](https://chromedriver.storage.googleapis.com/index.html?path=87.0.4280.20/)
267+
or [firefox driver](https://github.com/mozilla/geckodriver/releases)
268+
and unpack it into /usr/bin or /usr/local/bin. See the
269+
[selenium website](https://www.selenium.dev/selenium/docs/api/py/index.html)
270+
for further information on the setup

data/.gitkeep

Whitespace-only changes.

deep_cave/__init__.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
"""
2+
3+
.. code:: python
4+
import deep_cave
5+
6+
config = {'lr': 1e8}
7+
fidelity = 2
8+
9+
with deep_cave.start_trial(config, fidelity) as trial:
10+
trial.log_metric(.5)
11+
12+
"""
13+
14+
# mlflow style access to API via __init__.py
15+
16+
from .logger import (
17+
start_trial,
18+
end_trial,
19+
start_study,
20+
end_study,
21+
log_surrogate
22+
)
23+
24+
from .store.state import (
25+
set_study,
26+
get_study,
27+
set_tracking_uri,
28+
get_tracking_uri,
29+
set_registry_uri,
30+
get_registry_uri
31+
)
32+
33+
__all__ = [
34+
'start_trial',
35+
'end_trial',
36+
'start_study',
37+
'end_study',
38+
'set_study',
39+
'get_study',
40+
'set_tracking_uri',
41+
'get_tracking_uri',
42+
'set_registry_uri',
43+
'get_registry_uri',
44+
'log_surrogate'
45+
]
46+
47+
from ._version import get_versions
48+
__version__ = get_versions()['version']
49+
del get_versions

0 commit comments

Comments
 (0)