A. Deploy Using Docker (Linux)#

This guide helps you deploy a Datasite server on your local machine or a virtual machine hosted in the cloud that is running Ubuntu or other Linux distrbution.

Prerequistes:#

Test Docker works#

To test your prerequisites were properly installed, try to run:

docker ps

or docker info.

This should not return any error. If it does, please check you have the right permissions to run Docker commands. In particular, you may need to add your user to the docker group. Refer to the post-installation steps for Docker at https://docs.docker.com/install/linux/linux-postinstall/ for more information.

To test that Docker can pull and run images, please run:

docker run hello-world

Running with sudo

You might need to run Docker commands using sudo, depending on your setup. In this case, please run sudo docker run hello-world to verify that

Server Deployment#

A one-liner convenience script is provided to launch your server using Docker. You can read the script before executing it.

Step 1: Download script#

Downloaded it as follows:

curl -o setup.sh https://raw.githubusercontent.com/OpenMined/PySyft/syft-setup-script/scripts/docker-setup.sh

Step 2: Execute script#

To deploy your server, a range of arguments are available to setup the type of server you would like to launch and its profile:

  • --version or -v: version of PySyft you’d like to setup

  • --name or -n: an arbitrary name you’d like to give the server

  • --side or -s: high or low (Default is high if not specified)

  • --root-password or -password: The password you’d like to set for the root user (Default is changethis if not specified)

  • --root-email or -email: The email you’d like to set for the root user (Default is info@openmined.org if not specified)

  • --type or -t: datasite or gateway

  • --port or -p: The intended port to be assigned

bash setup.sh -v {{VERSION}} -n {{SERVER_NAME}} -s {{SERVER_SIDE}} -t {{SERVER_TYPE}} -p {{PORT}} --password {{PASSWORD}} --email {{EMAIL}}

Note:

  • You can visit this part of the documentation to understand the different server types and their roles, and also the different server sides.

Example:#

An example of this command will look like below:

bash setup.sh -v 0.8.2-beta.6 -n my_server_1 -s high -t datasite -p 8081 --password mypassword --email myemail

To check that the server is up and running, run docker ps -a to see the docker container you deployed. You can also run curl localhost:8081.

With the server up and running, you have successfully deployed a PySyft Server on your machine!

Launch client in Jupyter Notebook#

In this step, you need a client server in order to interact with the PySyft server you just deployed. Here, the client consists of a Jupyter notebook running the same version of PySyft as the server served as a container. This is a convenient setup, but you can as well launch your own Jupyter Notebook in an environment with Python3.10+ and the desired PySyft version.

We need to start the client as follows:

docker run --rm -it --network=host openmined/syft-client:${VERSION}

where ${VERSION} is the version of PySyft Client you’d like to run. It must be the same as you passed before at deployment step.

Keeping the notebook running#

Often, the jupyter notebook instance dies once you exit the terminal. To make it long running even after you close the terminal for easy access, consider running the command in a screen or tmux session. See this link for more information on how to use screen: Screen Command or tmux: Tmux Command.

Accessing the notebook#

If you launched the command above on your local machine, you should see the local URL where the notebook is running and access it in the browser.

If you are running on a VM, it might require extra steps to access the notebook in your local browser. Considering that the above command is running a pre-packaged Jupyter notebook in a container that is mapped to the host network, there are several ways to access the notebook in your local browser.

How to reach your remote notebook in browser

  • You can use SSH port forwarding to access the notebook in your local browser. See this link for an example on how to do this: Jupyter SSH Port Forwarding

  • You could also open the port 8888 in the Network Security Group of the VM and access the notebook in your local browser by visiting http://<VM_IP>:8888.

If this step is successful, you will be taken to a Jupyter notebook interface in the browser. Please create a new notebook and run the following command to test your full setup is ready to be used:

import syft as sy

sy.login(url="localhost:80", email="[email protected]", password="changethis")

 # Please pass the URL, the email and password used to create the server. The above are the default ones used during server creation.

If everything works well, you should be able to login to a high-side or low-side server (depending on what you chose above). You can now start running PySyft commands on the client server to interact with the PySyft server you just deployed.