This notebook aims to give a brief explanation on how the association request works.
%load_ext autoreload
%autoreload 2
import syft as sy
import torch as th
sy.networks
name | host_or_ip | vpn_host_or_ip | protocol | port | admin_email | website | slack | slack_channel | |
---|---|---|---|---|---|---|---|---|---|
0 | omnet | 13.64.187.229 | 100.64.0.1 | http | 80 | support@openmined.org | https://www.openmined.org/ | https://slack.openmined.org/ | omnet |
1 | United Nations PET Lab (Mock) | 168.61.66.213 | 100.64.0.1 | http | 80 | support@openmined.org | https://www.openmined.org/ | https://slack.openmined.org/ | petlab |
hagrid launch test_network_1 network to docker:9081
hagrid launch test_domain_1 domain to docker:9082
NETWORK_HOST_IP = "localhost:9081"
domain = sy.login(email="info@openmined.org", password="changethis", port=9082)
vpn_status = domain.vpn_status()
vpn_status
DOMAIN_VPN_IP = vpn_status["host"]["ip"]
for peer in vpn_status["peers"]:
if peer["hostname"] == "test_network_1":
NETWORK_VPN_IP = peer["ip"]
print(DOMAIN_VPN_IP, NETWORK_VPN_IP)
# we need to refactor this so that the VPN IPs are not required to be supplied
domain.apply_to_network(
domain_vpn_ip=DOMAIN_VPN_IP,
network_vpn_ip=NETWORK_VPN_IP
)
network = sy.login(email="info@openmined.org", password="changethis", port=9081)
network.association.pandas()
associations = network.association.all()
request_id = int(associations[0]["association_id"])
network.association[request_id].accept()
import torch as th
x = th.Tensor([1,2,3])
x_ptr = x.send(domain, tags=["secret"])
domain.store
import syft as sy
import torch as th
NETWORK_HOST_IP="13.64.187.229"
network = sy.login(url=f"http://{NETWORK_HOST_IP}", port=80)
network.domains
host_or_ip | id | is_vpn | name | |
---|---|---|---|---|
0 | 100.64.0.2 | 3d405798bd374911900793e382db5242 | 1 | outrageous_oneill |
# you can use 3 different ways to get the proxy domain client
# with int row
domain_client = network.domains[0]
domain_client
<ProxyClient - outrageous_oneill: <UID: 3d405798bd374911900793e382db5242>>
# with id string
domain_client = network.domains["9a7fd94214e049f6871d3d21e274cd29"]
# with UID object
from syft.core.common.uid import UID
id = UID("9a7fd94214e049f6871d3d21e274cd29")
domain_client = network.domains[id]
# now we can actually use it
domain_client
domain_client.store
secret_ptr = domain_client.store[0]
try:
res = secret_ptr.get(delete_obj=False)
print("Now I can get", res)
except Exception as e:
print("Guest cant get")
domain_client.login(email="info@openmined.org", password="changethis")
domain_client.logged_in
try:
res = secret_ptr.get(delete_obj=False)
print("Now I can get", res)
except Exception as e:
print("Guest cant get")
domain_client.logout()
import syft as sy
sy.networks
NETWORK_HOST_IP="13.64.187.229"
network = sy.login(url=f"http://{NETWORK_HOST_IP}", port=80)
Connecting to http://13.64.187.229... No email and password defined in login() - connecting as anonymous user!!! done! Logging into omnet... done!
network.domains
host_or_ip | id | is_vpn | name | |
---|---|---|---|---|
0 | 100.64.0.2 | 3d405798bd374911900793e382db5242 | 1 | outrageous_oneill |
network.search(query=["secret"])
id | name | host_or_ip | is_vpn | |
---|---|---|---|---|
0 | 3d405798bd374911900793e382db5242 | outrageous_oneill | 100.64.0.2 | True |
oniel_guest = network.domains['3d405798bd374911900793e382db5242']
oniel_root = oniel_guest.login(email="info@openmined.org", password="changethis")
Logged in to outrageous_oneill as info@openmined.org
ptr = oniel_root.store['secret']
ptr.get()
tensor([1., 2., 3.])