|
| 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 |
0 commit comments