Skip to content

Commit 63242eb

Browse files
committed
branced to code-only and code-plus-data styles
1 parent e4217e1 commit 63242eb

File tree

24 files changed

+499
-163
lines changed

24 files changed

+499
-163
lines changed

README.md

Lines changed: 4 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -1,165 +1,6 @@
1-
# marathon-docker-template
2-
Template submission format for participating in Topcoder Marathon Matches.
1+
# marathon-docker-templates
2+
Template submission formats for participating in Topcoder Marathon Matches.
33
Information in the challenge specification always overrides information in this document.
44

5-
## Submission format
6-
Our template supports both the "submit data" and "submit code" submission styles. Your submission should be a single ZIP file with the following content:
7-
8-
```
9-
/solution
10-
solution.csv
11-
/code
12-
Dockerfile
13-
flags.txt // optional
14-
<your code>
15-
```
16-
17-
The file `/solution/solution.csv` is the output your algorithm generates on the provisional test set. The format of this file will be described in the challenge specification.
18-
19-
The `/code` directory should contain a dockerized version of your system that will be used to reproduce your results in a well defined, standardized way. This folder must contain a `Dockerfile` that will be used to build a docker container that will host your system during final testing. How you organize the rest of the contents of the `/code` folder is up to you, as long as it satisfies the requirements listed below in the Final testing section. This repository contains code created in a toy challenge, for demonstration only. See the [Sample challenge](#a-sample-challenge) section at the end of this document for details.
20-
21-
#### Notes:
22-
- During provisional testing only your `solution.csv` file will be used for scoring, however the tester tool will verify that your submission file conforms to the required format. This means that at least the `/code/Dockerfile` must be present from day 1, even if it doesn't describe any meaningful system to be built. However, we recommend that you keep working on the dockerized version of your code as the challenge progresses, especially if you are at or close to a prize winning rank on the provisional leaderboard.
23-
24-
- Make sure that your submission package is smaller than 500 MB. This means that if you use large files (external libraries, data files, pretained model files, etc) that won't fit into this limit, then your docker build process must download these from the net during building. There are several ways to achieve this, e.g. external libraries may be installed from a git repository, data files may be downloaded using `wget` or `curl` from Dropbox or Google Drive or any other public file hosting service. In any case always make sure that your build process is carefully tested end to end before you submit your package for final testing.
25-
26-
- During final testing your last submission file will be used to build your docker container.
27-
28-
- Make sure that the contents of the `/solution` and `/code` folders are in sync, i.e. your solution.csv file contains the exact output of the current version of your code.
29-
30-
## Final testing
31-
32-
To be able to successfully submit your system for final testing, some familiarity with [Docker](https://www.docker.com/) is required. If you have not used this technology before then you may first check [this page](https://www.docker.com/why-docker) and other learning material linked from there. To install Docker follow [these instructions](https://www.docker.com/community-edition).
33-
34-
In some contest you will work with GPU-accelerated systems in which case Nvidia-docker will also be required. See how to install Nvidia-docker [here](https://github.com/NVIDIA/nvidia-docker). Note that all sample `docker` commands given below should be replaced with `nvidia-docker` in this case.
35-
36-
## Contents of the /code folder
37-
The `/code` folder of your submission must contain:
38-
1. All your code (training and inference) that are needed to reproduce your results.
39-
2. A dockerfile (named `Dockerfile`, without extension) that will be used to build your system.
40-
3. All data files that are needed during training and inference, with the exception of
41-
- the contest's own training and testing data. You may assume that the training and testing data (as described in the problem statement's "Input files" section) will be available on the machine where your docker container runs, compressed files already unpacked,
42-
- large data files that can be downloaded automatically either during building or running your docker script.
43-
4. Your trained model file(s). Alternatively your build process may download your model files from the network. Either way, you must make it possible to run inference without having to execute training first.
44-
45-
The tester tool will unpack your submission, and the
46-
```
47-
docker build -t <id> .
48-
```
49-
command will be used to build your docker image (the final '.' is significant), where `<id>` is your TopCoder handle.
50-
51-
The build process must run out of the box, i.e. it should download and install all necessary 3rd party dependencies, either download from internet or copy from the unpacked submission all necessary external data files, your model files, etc.
52-
Your container will be started by the
53-
```
54-
docker run -v <local_data_path>:/data:ro -v <local_writable_area_path>:/wdata -it <id>
55-
```
56-
command, where the `-v` parameter mounts the contest's data to the container's `/data` folder. This means that all the raw contest data will be available for your container within the `/data` folder. Note that your container will have read only access to the `/data` folder. You can store large temporary files in the `/wdata` folder.
57-
58-
#### Custom docker options
59-
In some cases it may be necessary to pass custom options to the `docker` or `nvidia-docker` commands. If you need such flags, you should list them in a file named `flags.txt` and place this file in the `/code` folder of your submission. The file must contain a single line only. If this file exists then its content will be added to the options list of the `docker run` command.
60-
61-
Example:
62-
63-
If `flags.txt` contains:
64-
```
65-
--ipc=host --shm-size 4G
66-
```
67-
then the docker command will look like:
68-
```
69-
docker run --ipc=host --shm-size 4G -v <local_data_path>:/data:ro -v <local_writable_area_path>:/wdata -it <id>
70-
```
71-
72-
## Train and test scripts
73-
74-
Your container must contain a train and test (a.k.a. inference) script having the following specification. See the problem statement for further, problem specific requirements like the allowed time limits for these scripts.
75-
76-
### train.sh
77-
78-
`train.sh <data-folder>` should create any data files that your algorithm needs for running `test.sh` later. The supplied `<data-folder>` parameter points to a folder having training data in the same structure as is available for you during the coding phase. You may assume that the data folder path will be under `/data` within your container.
79-
80-
As its first step `train.sh` must delete the self-created models shipped with your submission.
81-
82-
Some algorithms may not need any training at all. It is a valid option to leave `train.sh` empty, but the file must exist nevertheless.
83-
84-
Training should be possible to do with working with only the contest's own training data and publicly available external data. This means that this script should do all the preprocessing and training steps that are necessary to reproduce your complete training work flow.
85-
86-
A sample call to your training script:
87-
```
88-
./train.sh /data/train/
89-
```
90-
91-
In this case you can assume that the training data looks like this:
92-
```
93-
data/
94-
train/
95-
// all raw training data,
96-
// e.g. images and annotations
97-
```
98-
99-
### test.sh
100-
101-
`test.sh <data-folder> <output_path>` should run your inference code using new, unlabeled data and should generate an output CSV file, as specified by the problem statement. You may assume that the data folder path will be under `/data`.
102-
103-
Inference should be possible to do without running training first, i.e. using only your prebuilt model files.
104-
105-
It should be possible to execute your inference script multiple times on the same input data or on different input data. You must make sure that these executions don't interfere, each execution leaves your system in a state in which further executions are possible.
106-
107-
A sample call to your testing script (single line):
108-
```
109-
./test.sh /data/test/ solution.csv
110-
```
111-
In this case you can assume that the testing data looks like this:
112-
```
113-
data/
114-
test/
115-
// all raw testing data,
116-
// e.g. unlabeled images
117-
```
118-
## Code requirements
119-
Your training and inference scripts must output progress information. This may be as detailed as you wish but at the minimum it should contain the number of test cases processed so far.
120-
121-
Your testing code must process the test and validation data the same way, that is it must not contain any conditional logic based on whether it works on data that you have already downloaded or on unseen data.
122-
123-
Your `Dockerfile` must not contain `CMD` or `ENTRYPOINT` commands.
124-
125-
Your `Dockerfile` must contain a `WORKDIR` command that makes sure that when the container starts the `test.sh` and `train.sh` scripts will be found in the current directory.
126-
127-
128-
## Verification workflow
129-
1. `test.sh` is run on the provisional test set to verify that the results of your latest online submission can be reproduced. This test run uses your home built models.
130-
2. `test.sh` is run on the final validation dataset, again using your home built models. Your final score is the one that your system achieves in this step.
131-
3. `train.sh` is run on the full training dataset to verify that your training process is reproducible. After the training process finishes, further executions of the test script must use the models generated in this step.
132-
4. `test.sh` is run on the final validation dataset (or on a subset of that), using the models generated in the previous step, to verify that the results achieved in step #2 above can be reproduced.
133-
134-
A note on reproducibility: we are aware that it is not always possible to reproduce the exact same results. E.g. if you do online training then the difference in the training environments may result in different number of iterations, meaning different models. Also you may have no control over random number generation in certain 3rd party libraries. In any case, the results must be statistically similar, and in case of differences you must have a convincing explanation why the same result can not be reproduced.
135-
136-
## A sample challenge
137-
For demonstration only, this repository contains code for a hypothetical challenge in which your task is to predict weight of people based on their height. To illustrate the task, the `code/data` folder contains a simple training and testing file. These files generally need not be part of your submission, in this case this is added only so that you can test the sample code.
138-
139-
Assume that in this challenge `train.sh` is specified to take a single parameter: the location of a file containing training data. In a typical challange this would rather be a folder containg several files that store training data, but for simplicity we have a single training file now.
140-
141-
Similarly, `test.sh` takes two parameters: path to a testing file (again, in real challenges this is typically a folder) and an output file name.
142-
143-
Both these scripts forward their parameters to a solution written in Java, and they also pass an internal parameter: the location of a simple 'model' file. This demonstrates that the communication between the train and test scrips and the rest of your system is up to you, the testing environment is only interested in whether you comply to the input / output requirements of the train and test scripts.
144-
145-
During training the `sample.submission.Tester` class calculates linear regression parameters from the provided training data, which is written to `/model/dummy-model.txt` and this will be used during testing by the `sample.submission.Tester` class. Make sure that the model files required during testing are already packaged in your submission (or downloaded during building your container), so that testing is possible without running training first.
146-
147-
### Running the sample
148-
Build the container from within the `/code` folder by
149-
`docker build -t docker-template .`
150-
151-
Note that the build process makes sure that the Java files get compiled.
152-
153-
Launch the container with
154-
`docker run -it docker-template`
155-
156-
Verify that testing works out of the box. Within the container, run
157-
`./test.sh ./data/testing.txt ./data/solution.csv`
158-
159-
This should create a `solution.csv` file within the `/data` folder. This should be identical that is already present in the submission's `/solution` folder.
160-
161-
Verify that training works:
162-
`./train.sh ./data/training.txt`
163-
164-
This should overwrite the `/model/dummy-model.txt` file, so subsequent testing will use the new model instead of the one shipped with the submission.
165-
5+
See `/data-plus-code-style` if your contest requires data submissions during the online submission phase and code during final testing.
6+
See `/code-only-style` if you need to submit code already in the provisional testing phase.

0 commit comments

Comments
 (0)