This repository is no longer maintained. Vantage6 now provides a flexible algorithm boilerplate generator. You can use that via the vantage6 command line interface command v6 algorithm create
. For more details, see https://docs.vantage6.ai/en/main/algorithms/develop.html.
This algorithm is part of the vantage6 solution. Vantage6 allowes to execute computations on federated datasets. This repository provides a boilerplate for new algorithms.
First clone the repository.
# Clone this repository
git clone https://github.com/IKNL/v6-boilerplate-py
Rename the directories to something that fits your algorithm, we use the convention v6-{name}-{language}
. Then you can edit the following files:
Update the ARG PKG_NAME=...
to the name of your algorithm (preferable the same as the directory name).
Determine which license suits your project.
This file contains all the methods that can be called at the nodes. In the example below, one example function is shown.
import pandas as pd
from vantage6.client.algorithm_client import AlgorithmClient
@algorithm_client
@data(1)
def my_function(client: AlgorithmClient, df1: pd.DataFrame, column_name: str):
pass
This function uses an
@algorithm_client
decorator to insert an algorithm client, which can be used
to e.g. create subtasks or find the VPN addresses of algorithm containers
within the same task running on other nodes. Also, the @data
decorator is
used to insert a single pandas dataframe.
This requires the user creating a task to specify one database when calling
this function. Note that you can specify any number x
in data(x)
.
The number that you specify will determine how many databases will be added to
your function profile.
In order for the Docker image to find the methods the algorithm needs to be installable. Make sure the name matches the ARG PKG_NAME
in the Dockerfile.
Also, make sure to add any dependencies that your algorithm needs to setup.py
and requirements.txt
!
See the documentation for detailed instructions on how to install and use the server and nodes.