|
| 1 | +# OpenML Python Container |
| 2 | + |
| 3 | +This docker container has the latest development version of openml-python downloaded and pre-installed. |
| 4 | +It can be used to run the unit tests or build the docs in a fresh and/or isolated unix environment. |
| 5 | +Instructions only tested on a Windows host machine. |
| 6 | + |
| 7 | +First pull the docker image: |
| 8 | + |
| 9 | + docker pull openml/openml-python |
| 10 | + |
| 11 | +## Usage |
| 12 | + |
| 13 | + |
| 14 | + docker run -it openml/openml-python [DOC,TEST] [BRANCH] |
| 15 | + |
| 16 | +The image is designed to work with two specified directories which may be mounted ([`docker --mount documentation`](https://docs.docker.com/storage/bind-mounts/#start-a-container-with-a-bind-mount)). |
| 17 | +You can mount your openml-python folder to the `/code` directory to run tests or build docs on your local files. |
| 18 | +You can mount an `/output` directory to which the container will write output (currently only used for docs). |
| 19 | +Each can be mounted by adding a `--mount type=bind,source=SOURCE,destination=/DESTINATION` where `SOURCE` is the absolute path to your code or output directory, and `DESTINATION` is either `code` or `output`. |
| 20 | + |
| 21 | +E.g. mounting a code directory: |
| 22 | + |
| 23 | + docker run -i --mount type=bind,source="E:\\repositories/openml-python",destination="/code" -t openml/openml-python |
| 24 | + |
| 25 | +E.g. mounting an output directory: |
| 26 | + |
| 27 | + docker run -i --mount type=bind,source="E:\\files/output",destination="/output" -t openml/openml-python |
| 28 | + |
| 29 | +You can mount both at the same time. |
| 30 | + |
| 31 | +### Bash (default) |
| 32 | +By default bash is invoked, you should also use the `-i` flag when starting the container so it processes input: |
| 33 | + |
| 34 | + docker run -it openml/openml-python |
| 35 | + |
| 36 | +### Building Documentation |
| 37 | +There are two ways to build documentation, either directly from the `HEAD` of a branch on Github or from your local directory. |
| 38 | + |
| 39 | +#### Building from a local repository |
| 40 | +Building from a local directory requires you to mount it to the ``/code`` directory: |
| 41 | + |
| 42 | + docker run --mount type=bind,source=PATH_TO_REPOSITORY,destination=/code -t openml/openml-python doc |
| 43 | + |
| 44 | +The produced documentation will be in your repository's ``doc/build`` folder. |
| 45 | +If an `/output` folder is mounted, the documentation will *also* be copied there. |
| 46 | + |
| 47 | +#### Building from an online repository |
| 48 | +Building from a remote repository requires you to specify a branch. |
| 49 | +The branch may be specified by name directly if it exists on the original repository (https://github.com/openml/openml-python/): |
| 50 | + |
| 51 | + docker run --mount type=bind,source=PATH_TO_OUTPUT,destination=/output -t openml/openml-python doc BRANCH |
| 52 | + |
| 53 | +Where `BRANCH` is the name of the branch for which to generate the documentation. |
| 54 | +It is also possible to build the documentation from the branch on a fork, in this case the `BRANCH` should be specified as `GITHUB_NAME#BRANCH` (e.g. `PGijsbers#my_feature`) and the name of the forked repository should be `openml-python`. |
| 55 | + |
| 56 | +### Running tests |
| 57 | +There are two ways to run tests, either directly from the `HEAD` of a branch on Github or from your local directory. |
| 58 | +It works similar to building docs, but should specify `test` as mode. |
| 59 | +For example, to run tests on your local repository: |
| 60 | + |
| 61 | + docker run --mount type=bind,source=PATH_TO_REPOSITORY,destination=/code -t openml/openml-python test |
| 62 | + |
| 63 | +Running tests from the state of an online repository is supported similar to building documentation (i.e. specify `BRANCH` instead of mounting `/code`). |
| 64 | + |
| 65 | +## Troubleshooting |
| 66 | + |
| 67 | +When you are mounting a directory you can check that it is mounted correctly by running the image in bash mode. |
| 68 | +Navigate to the `/code` and `/output` directories and see if the expected files are there. |
| 69 | +If e.g. there is no code in your mounted `/code`, you should double-check the provided path to your host directory. |
| 70 | + |
| 71 | +## Notes for developers |
| 72 | +This section contains some notes about the structure of the image, intended for those who want to work on it. |
| 73 | + |
| 74 | +### Added Directories |
| 75 | +The `openml/openml-python` image is built on a vanilla `python:3` image. |
| 76 | +Additionally it contains the following files are directories: |
| 77 | + |
| 78 | + - `/omlp`: contains the openml-python repository in the state with which the image was built by default. |
| 79 | + If working with a `BRANCH`, this repository will be set to the `HEAD` of `BRANCH`. |
| 80 | + - `/omlp/venv/`: contains the used virtual environment for `doc` and `test`. It has `openml-python` dependencies pre-installed. |
| 81 | + When invoked with `doc` or `test`, the dependencies will be updated based on the `setup.py` of the `BRANCH` or mounted `/code`. |
| 82 | + - `/scripts/startup.sh`: the entrypoint of the image. Takes care of the automated features (e.g. `doc` and `test`). |
| 83 | + |
| 84 | +## Building the image |
| 85 | +To build the image yourself, execute `docker build -f Dockerfile .` from this directory. |
| 86 | +It will use the `startup.sh` as is, so any local changes will be present in the image. |
0 commit comments