|
1 | 1 | # OpenML Python Container |
2 | 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. |
| 3 | +This docker container has the latest version of openml-python downloaded and pre-installed. |
| 4 | +It can also be used by developers to run unit tests or build the docs in |
| 5 | +a fresh and/or isolated unix environment. |
| 6 | +This document contains information about: |
6 | 7 |
|
7 | | -First pull the docker image: |
| 8 | + 1. [Usage](#usage): how to use the image and its main modes. |
| 9 | + 2. [Using local or remote code](#using-local-or-remote-code): useful when testing your own latest changes. |
| 10 | + 3. [Versions](#versions): identify which image to use. |
| 11 | + 4. [Development](#for-developers): information about the Docker image for developers. |
8 | 12 |
|
9 | | - docker pull openml/openml-python |
| 13 | +*note:* each docker image is shipped with a readme, which you can read with: |
| 14 | +`docker run --entrypoint=/bin/cat openml/openml-python:TAG readme.md` |
10 | 15 |
|
11 | 16 | ## Usage |
12 | 17 |
|
| 18 | +There are three main ways to use the image: running a pre-installed Python environment, |
| 19 | +running tests, and building documentation. |
13 | 20 |
|
14 | | - docker run -it openml/openml-python [DOC,TEST] [BRANCH] |
| 21 | +### Running `Python` with pre-installed `OpenML-Python` (default): |
15 | 22 |
|
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: |
| 23 | +To run `Python` with a pre-installed `OpenML-Python` environment run: |
22 | 24 |
|
23 | | - docker run -i --mount type=bind,source="E:\\repositories/openml-python",destination="/code" -t openml/openml-python |
| 25 | +```text |
| 26 | +docker run -it openml/openml-python |
| 27 | +``` |
24 | 28 |
|
25 | | -E.g. mounting an output directory: |
| 29 | +this accepts the normal `Python` arguments, e.g.: |
26 | 30 |
|
27 | | - docker run -i --mount type=bind,source="E:\\files/output",destination="/output" -t openml/openml-python |
| 31 | +```text |
| 32 | +docker run openml/openml-python -c "import openml; print(openml.__version__)" |
| 33 | +``` |
28 | 34 |
|
29 | | -You can mount both at the same time. |
| 35 | +if you want to run a local script, it needs to be mounted first. Mount it into the |
| 36 | +`openml` folder: |
30 | 37 |
|
31 | | -### Bash (default) |
32 | | -By default bash is invoked, you should also use the `-i` flag when starting the container so it processes input: |
| 38 | +``` |
| 39 | +docker run -v PATH/TO/FILE:/openml/MY_SCRIPT.py openml/openml-python MY_SCRIPT.py |
| 40 | +``` |
33 | 41 |
|
34 | | - docker run -it openml/openml-python |
| 42 | +### Running unit tests |
35 | 43 |
|
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. |
| 44 | +You can run the unit tests by passing `test` as the first argument. |
| 45 | +It also requires a local or remote repository to be specified, which is explained |
| 46 | +[below]((#using-local-or-remote-code). For this example, we specify to test the |
| 47 | +`develop` branch: |
38 | 48 |
|
39 | | -#### Building from a local repository |
40 | | -Building from a local directory requires you to mount it to the ``/code`` directory: |
| 49 | +```text |
| 50 | +docker run openml/openml-python test develop |
| 51 | +``` |
41 | 52 |
|
42 | | - docker run --mount type=bind,source=PATH_TO_REPOSITORY,destination=/code -t openml/openml-python doc |
| 53 | +### Building documentation |
43 | 54 |
|
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. |
| 55 | +You can build the documentation by passing `doc` as the first argument, |
| 56 | +you should [mount]((https://docs.docker.com/storage/bind-mounts/#start-a-container-with-a-bind-mount)) |
| 57 | +an output directory in which the docs will be stored. You also need to provide a remote |
| 58 | +or local repository as explained in [the section below]((#using-local-or-remote-code). |
| 59 | +In this example, we build documentation for the `develop` branch. |
| 60 | +On Windows: |
46 | 61 |
|
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/): |
| 62 | +```text |
| 63 | + docker run --mount type=bind,source="E:\\files/output",destination="/output" openml/openml-python doc develop |
| 64 | +``` |
50 | 65 |
|
51 | | - docker run --mount type=bind,source=PATH_TO_OUTPUT,destination=/output -t openml/openml-python doc BRANCH |
| 66 | +on Linux: |
| 67 | +```text |
| 68 | + docker run --mount type=bind,source="./output",destination="/output" openml/openml-python doc develop |
| 69 | +``` |
| 70 | + |
| 71 | +see [the section below]((#using-local-or-remote-code) for running against local changes |
| 72 | +or a remote branch. |
52 | 73 |
|
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`. |
| 74 | +*Note: you can forgo mounting an output directory to test if the docs build successfully, |
| 75 | +but the result will only be available within the docker container under `/openml/docs/build`.* |
55 | 76 |
|
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: |
| 77 | +## Using local or remote code |
60 | 78 |
|
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 |
| 79 | +You can build docs or run tests against your local repository or a Github repository. |
| 80 | +In the examples below, change the `source` to match the location of your local repository. |
| 81 | + |
| 82 | +### Using a local repository |
| 83 | + |
| 84 | +To use a local directory, mount it in the `/code` directory, on Windows: |
| 85 | + |
| 86 | +```text |
| 87 | + docker run --mount type=bind,source="E:\\repositories/openml-python",destination="/code" openml/openml-python test |
| 88 | +``` |
66 | 89 |
|
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. |
| 90 | +on Linux: |
| 91 | +```text |
| 92 | + docker run --mount type=bind,source="/Users/pietergijsbers/repositories/openml-python",destination="/code" openml/openml-python test |
| 93 | +``` |
70 | 94 |
|
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. |
| 95 | +when building docs, you also need to mount an output directory as shown above, so add both: |
| 96 | + |
| 97 | +```text |
| 98 | +docker run --mount type=bind,source="./output",destination="/output" --mount type=bind,source="/Users/pietergijsbers/repositories/openml-python",destination="/code" openml/openml-python doc |
| 99 | +``` |
| 100 | + |
| 101 | +### Using a Github repository |
| 102 | +Building from a remote repository requires you to specify a branch. |
| 103 | +The branch may be specified by name directly if it exists on the original repository (https://github.com/openml/openml-python/): |
| 104 | + |
| 105 | + docker run --mount type=bind,source=PATH_TO_OUTPUT,destination=/output openml/openml-python [test,doc] BRANCH |
| 106 | + |
| 107 | +Where `BRANCH` is the name of the branch for which to generate the documentation. |
| 108 | +It is also possible to build the documentation from the branch on a fork, |
| 109 | +in this case the `BRANCH` should be specified as `GITHUB_NAME#BRANCH` (e.g. |
| 110 | +`PGijsbers#my_feature_branch`) and the name of the forked repository should be `openml-python`. |
| 111 | + |
| 112 | +## For developers |
| 113 | +This section contains some notes about the structure of the image, |
| 114 | +intended for those who want to work on it. |
73 | 115 |
|
74 | 116 | ### Added Directories |
75 | 117 | 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`. |
| 118 | +Additionally, it contains the following files are directories: |
| 119 | + |
| 120 | + - `/openml`: contains the openml-python repository in the state with which the image |
| 121 | + was built by default. If working with a `BRANCH`, this repository will be set to |
| 122 | + the `HEAD` of `BRANCH`. |
| 123 | + - `/openml/venv/`: contains the used virtual environment for `doc` and `test`. It has |
| 124 | + `openml-python` dependencies pre-installed. When invoked with `doc` or `test`, the |
| 125 | + dependencies will be updated based on the `setup.py` of the `BRANCH` or mounted `/code`. |
82 | 126 | - `/scripts/startup.sh`: the entrypoint of the image. Takes care of the automated features (e.g. `doc` and `test`). |
83 | 127 |
|
84 | 128 | ## 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. |
| 129 | +To build the image yourself, execute `docker build -f Dockerfile .` from the `docker` |
| 130 | +directory of the `openml-python` repository. It will use the `startup.sh` as is, so any |
| 131 | +local changes will be present in the image. |
0 commit comments