-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathload_data_remote.py
More file actions
41 lines (32 loc) · 1.27 KB
/
load_data_remote.py
File metadata and controls
41 lines (32 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python3
from __future__ import annotations
import uuid
from typing import List, Dict
import numpy as np
import pandas as pd
import syft as sy
# ------------------------------------------------------------------
SITES: List[Dict[str, str | int]] = [
{"host": "gaia2-vm-1.imsi.athenarc.gr", "port": 8090},
{"host": "gaia2-vm-2.imsi.athenarc.gr", "port": 8090},
{"host": "gaia2-vm-3.imsi.athenarc.gr", "port": 8090},
]
# ------------------------------------------------------------------
EMAIL = "info@openmined.org"
PASSWORD = "changethis"
rng = np.random.default_rng(0)
def upload(client: sy.Client, rows: int, idx: int) -> None:
df = pd.DataFrame({"x": rng.normal(size=rows), "y": rng.normal(size=rows)})
tag = f"site{idx+1}-{uuid.uuid4().hex[:6]}"
asset = sy.Asset(name=f"{tag} asset", data=df, mock=df.head())
client.upload_dataset(sy.Dataset(name=tag, asset_list=[asset]))
print(f"Dataset '{tag}' uploaded to {client.name} ({rows} rows)")
def main():
for idx, site in enumerate(SITES):
host, port = site["host"], site["port"]
url = f"http://{host}:{port}"
client = sy.login(email=EMAIL, password=PASSWORD, url=url)
rows = 200 + idx * 100
upload(client, rows, idx)
if __name__ == "__main__":
main()