|
| 1 | +Working with the `coco` code base |
| 2 | +================================= |
| 3 | + |
| 4 | +## Before you start |
| 5 | + |
| 6 | +To work with the `coco` source code, you need quite a few tools in very specific versions. |
| 7 | +We provide a Conda environment file `env.yaml` and recommend you use it to setup your development environment. |
| 8 | +It is regularly tested on Linux, Windows and macOS and is what is used in CI. |
| 9 | + |
| 10 | +Following these steps should setup a fresh `coco` environment: |
| 11 | + |
| 12 | +1. Create or update a new conda environment with all the requirements by running |
| 13 | + |
| 14 | + ```sh |
| 15 | + conda env create -f env.yaml |
| 16 | + ``` |
| 17 | + or if you've already setup a `coco` environment |
| 18 | + ```sh |
| 19 | + conda env update -f env.yaml --prune |
| 20 | + ``` |
| 21 | + |
| 22 | +1. Activate environment |
| 23 | + ```sh |
| 24 | + conda activate coco |
| 25 | + ``` |
| 26 | + |
| 27 | +You now have all required dependencies to work on the code base. |
| 28 | +If you notice that something is missing, please let us know by opening an [issue](https://github.com/numbbo/coco/issues/new/choose). |
| 29 | + |
| 30 | +## Working with the Experimental Code |
| 31 | + |
| 32 | +Before any of the bindings can be built and after every change to the core files (in `code-experiments/src/`), you need to run `scripts/fabricate`. |
| 33 | +The job of `fabricate` is to bundle the C files and place them in all the right places so that the language specific build tools can find them when building the respective bindings. |
| 34 | +`fabricate` also updates the binding metadata to include version information and any other changes that need to be made from one build to the next. |
| 35 | +It is harmless to run `fabricate` too often, but forgetting to run it means you might be using stale sources. |
| 36 | + |
| 37 | +### Running unit tests |
| 38 | + |
| 39 | +Change to the unit tests directory |
| 40 | +```sh |
| 41 | +cd code-experiments/test/unit-test |
| 42 | +``` |
| 43 | + |
| 44 | +Rerun `fabricate` if not already done |
| 45 | +```sh |
| 46 | +python ../../../scripts/fabricate |
| 47 | +``` |
| 48 | + |
| 49 | +Build tests using [`cmake`](https://cmake.org/cmake/help/latest/manual/cmake.1.html) |
| 50 | +```sh |
| 51 | +cmake -B build |
| 52 | +cmake --build build |
| 53 | +``` |
| 54 | + |
| 55 | +Run tests using [`ctest`](https://cmake.org/cmake/help/latest/manual/ctest.1.html) |
| 56 | +```sh |
| 57 | +ctest --test-dir build |
| 58 | +``` |
| 59 | + |
| 60 | +### Regression tests |
| 61 | + |
| 62 | +Note that I'm not sure the regression tests are really useful at the moment. But here goes: |
| 63 | + |
| 64 | +Change to the regression tests directory |
| 65 | +```sh |
| 66 | +cd code-experiments/test/regression-test |
| 67 | +``` |
| 68 | + |
| 69 | +The regression tests require the `cocoex` Python package. Install it first |
| 70 | +```sh |
| 71 | +python -m pip uninstall -y cocoex |
| 72 | +python -m pip install ../../build/python/ |
| 73 | +``` |
| 74 | + |
| 75 | +Now run the regression tests |
| 76 | + |
| 77 | +```sh |
| 78 | +python test_suites.py |
| 79 | +``` |
| 80 | +and |
| 81 | +```sh |
| 82 | +python test_logger.py |
| 83 | +``` |
| 84 | + |
| 85 | +### Integration tests |
| 86 | + |
| 87 | +Still need to fix those up. |
| 88 | + |
| 89 | +### `cocoex` Python package |
| 90 | + |
| 91 | +Change to the `cocoex` Python package directory |
| 92 | +```sh |
| 93 | +cd code-experiments/build/python |
| 94 | +``` |
| 95 | + |
| 96 | +Install the package from source |
| 97 | +```sh |
| 98 | +pip uninstall -y cocoex |
| 99 | +pip install . |
| 100 | +``` |
| 101 | + |
| 102 | +Install and run `pytest` |
| 103 | +```sh |
| 104 | +pip install pytest |
| 105 | +python -m pytest test |
| 106 | +``` |
| 107 | + |
| 108 | +## Working with the Postprocessing Code |
| 109 | + |
| 110 | +Before you begin, always run `python scripts/fabricate` to update any auto-generated files. |
| 111 | +Then, you can install the `cocopp` package using pip: |
| 112 | + |
| 113 | +```sh |
| 114 | +python -m pip uninstall -y cocopp |
| 115 | +python -m pip install code-postprocessing |
| 116 | +``` |
| 117 | + |
| 118 | +If you are working on `cocopp`, you can use an editable install and Python will pick up any changes you make without having to reinstall: |
| 119 | + |
| 120 | +```sh |
| 121 | +python -m pip uninstall -y cocopp |
| 122 | +python -m pip install --editable code-postprocessing |
| 123 | +``` |
0 commit comments