This is a base image for MIP algorithms implemented in Python.
Run: ./build.sh
Run: ./tests/test.sh
Run: ./publish.sh
- Extend a version of hbpmip/python-mip image (see Dockerfile example below);
- Add
from mip_helper import mip_helper
in your Python script to import the library; - Call
mip_helper.fetch_data()
to get the input data (formatted like described below); - Call
mip_helper.save_results(pfa, shape)
ormip_helper.save_error(error)
to store the results; - Ensure that your Dockerfile copies the needed files, sets up a valid entry-point and sets up a FUNCTION environment variable containing the algorithm name (see Dockerfile example below).
The mip_helper.fetch_data()
function returns a dictionary.
Here is a complete example:
{
"data": {
"dependent": [
{
"name": "alzheimerbroadcategories",
"type": {
"name": "polynominal",
"enumeration": [
"AD",
"CN",
"Other"
]
},
"series": [
"AD",
"CN",
"CN"
]
}
],
"independent": [
{
"name": "rigthhippocampus",
"type": {
"name": "real"
},
"series": [
1.9,
5.6,
4.2
]
},
{
"name": "lefthippocampus",
"type": {
"name": "real"
},
"series": [
1.9,
5.6,
4.2
]
}
]
},
"parameters": [
{
"name": "k",
"value": 42
}
]
}
FROM hbpmip/python-mip:0.7.8
ENV FUNCTION python-anova
COPY requirements.txt /requirements.txt
COPY anova.py /anova.py
RUN conda install -y --file /requirements.txt
ENTRYPOINT ["python", "/anova.py"]
Here is a list of future improvements:
- Extract the scripts in a proper library sub-project, publish it on PyPI and install it properly in the python-mip image
- Provide separate images for the building (based on Debian and including tools like conda) and for the distribution (based on Alpine and including a minimal Python environment).
- Add some tests