Package & distribute
Once the algorithm is completed it needs to be packaged and made available for retrieval by the nodes. The algorithm is packaged in a Docker image. A Docker image is created from a Dockerfile, which acts as blue-print. Once the Docker image is created it needs to be uploaded to a registry so that nodes can retrieve it.
Dockerfile
A minimal Dockerfile should include a base-image, injecting your algorithm and execution command of your algorithm. For example:
# python3 image as base
FROM python:3
# copy your algorithm in the container
COPY . /app
# maybe your algorithm is installable.
RUN pip install /app
# execute your application
CMD python /app/app.pyWhen using the Python wrapper the Dockerfile needs to follow a certain format. You should only change the PKG_NAME value to the Python package name of your algorithm.
# python vantage6 algorithm base image
FROM harbor.vantage6.ai/algorithms/algorithm-base
# this should reflect the python package name
ARG PKG_NAME="v6-summary-py"
# install federated algorithm
COPY . /app
RUN pip install /app
ENV PKG_NAME=${PKG_NAME}
# Tell docker to execute `docker_wrapper()` when the image is run.
CMD python -c "from vantage6.tools.docker_wrapper import docker_wrapper; docker_wrapper('${PKG_NAME}'When using the R wrapper the Dockerfile needs to follow a certain format. You should only change the PKG_NAME value to the R package name of your algorithm.
Additional Docker directives are needed when using direct communication between different algorithm containers, see Networking for more information on this.
Build & upload
If you are in the folder containing the Dockerfile, you can build the project as follows:
The -t indicated the name of your image. This name is also used as reference where the image is located on the internet. If you use Docker hub to store your images, you only specify your username as repo followed by your image name and tag: USERNAME/IMAGE_NAME:IMAGE_TAG. When using a private registry repo should contain the URL of the registry also: e.g. harbor2.vantage6.ai/PROJECT/IMAGE_NAME:TAG.
Then you can push you image:
Now that is has been uploaded it is available for nodes to retrieve when they need it.
Signed images
It is possible to use the Docker the framework to create signed images. When using signed image the node can verify the author of the algorithm image adding an additional protection layer.
Dockerfile
Build project
CMD
Expose
Harbor or Docker hub or whatever
public vs private
signed
Last updated
Was this helpful?