Skip to content

Commit

Permalink
Merge pull request #8159 from kiendang/client-login-new
Browse files Browse the repository at this point in the history
Return a new client with SyftClient.login
  • Loading branch information
kiendang authored Oct 19, 2023
2 parents 49277f6 + da90a14 commit 1bae336
Show file tree
Hide file tree
Showing 24 changed files with 183 additions and 200 deletions.
78 changes: 40 additions & 38 deletions notebooks/tutorials/enclaves/Enclave-single-notebook-DO-DS.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@
"metadata": {},
"outputs": [],
"source": [
"#Local Python Mode\n",
"enclave_node = sy.orchestra.launch(name=\"Enclave\",\n",
" node_type=sy.NodeType.ENCLAVE,\n",
" local_db=True,\n",
" dev_mode=True,\n",
" reset=True)"
"# Local Python Node\n",
"enclave_node = sy.orchestra.launch(\n",
" name=\"Enclave\",\n",
" node_type=sy.NodeType.ENCLAVE,\n",
" local_db=True,\n",
" dev_mode=True,\n",
" reset=True\n",
")"
]
},
{
Expand Down Expand Up @@ -69,14 +71,18 @@
"metadata": {},
"outputs": [],
"source": [
"ca_node = sy.orchestra.launch(name=\"Canada\",\n",
" local_db=True,\n",
" reset=True,\n",
" dev_mode=True)\n",
"it_node = sy.orchestra.launch(name=\"Italy\",\n",
" local_db=True,\n",
" reset=True,\n",
" dev_mode=True) "
"ca_node = sy.orchestra.launch(\n",
" name=\"Canada\",\n",
" local_db=True,\n",
" reset=True,\n",
" dev_mode=True\n",
")\n",
"it_node = sy.orchestra.launch(\n",
" name=\"Italy\",\n",
" local_db=True,\n",
" reset=True,\n",
" dev_mode=True\n",
") "
]
},
{
Expand Down Expand Up @@ -105,11 +111,13 @@
"metadata": {},
"outputs": [],
"source": [
"gateway_node = sy.orchestra.launch(name=\"gateway\",\n",
" node_type = sy.NodeType.GATEWAY,\n",
" local_db=True,\n",
" reset=True,\n",
" dev_mode=True)"
"gateway_node = sy.orchestra.launch(\n",
" name=\"gateway\",\n",
" node_type = sy.NodeType.GATEWAY,\n",
" local_db=True,\n",
" reset=True,\n",
" dev_mode=True\n",
")"
]
},
{
Expand Down Expand Up @@ -334,7 +342,7 @@
"metadata": {},
"outputs": [],
"source": [
"#Explore the domains and enclaves connected to the gateway\n",
"# Explore the domains and enclaves connected to the gateway\n",
"ds_gateway_client.domains"
]
},
Expand All @@ -345,9 +353,9 @@
"metadata": {},
"outputs": [],
"source": [
"#logs into canada as proxy_client\n",
"# Log into canada as proxy_client\n",
"ds_ca_proxy_client = ds_gateway_client.domains[0]\n",
"ds_ca_proxy_client.login(email=\"[email protected]\" , password=\"changethis\")\n",
"ds_ca_proxy_client = ds_ca_proxy_client.login(email=\"[email protected]\", password=\"changethis\")\n",
"assert ds_ca_proxy_client.name == \"Canada\"\n",
"assert ds_ca_proxy_client.connection.proxy_target_uid == do_ca_client.id\n",
"assert isinstance(ds_ca_proxy_client, DomainClient)"
Expand All @@ -360,9 +368,9 @@
"metadata": {},
"outputs": [],
"source": [
"#logs into italy as proxy_client\n",
"# Log into italy as proxy_client\n",
"ds_it_proxy_client = ds_gateway_client.domains[1]\n",
"ds_it_proxy_client.login(email=\"[email protected]\" , password=\"changethis\")\n",
"ds_it_proxy_client = ds_it_proxy_client.login(email=\"[email protected]\", password=\"changethis\")\n",
"assert ds_it_proxy_client.name == \"Italy\"\n",
"assert ds_it_proxy_client.connection.proxy_target_uid == do_it_client.id\n",
"assert isinstance(ds_it_proxy_client, DomainClient)"
Expand All @@ -375,9 +383,11 @@
"metadata": {},
"outputs": [],
"source": [
"# Creates and account and logs into enclave as proxy client\n",
"# Create an account and log into enclave as proxy client\n",
"ds_enclave_proxy_client = ds_gateway_client.enclaves[0]\n",
"ds_enclave_proxy_client.login(email=\"[email protected]\" , password=\"changethis\",name=\"Sheldon\", register=True)\n",
"ds_enclave_proxy_client = ds_enclave_proxy_client.login(\n",
" email=\"[email protected]\" , password=\"changethis\", name=\"Sheldon\", register=True\n",
")\n",
"assert ds_enclave_proxy_client.name == \"Enclave\"\n",
"assert ds_enclave_proxy_client.connection.proxy_target_uid == enclave_guest_client.id\n",
"assert isinstance(ds_enclave_proxy_client, EnclaveClient)"
Expand Down Expand Up @@ -453,11 +463,11 @@
"metadata": {},
"outputs": [],
"source": [
"#Checking result of mock data execution\n",
"# Check result of mock data execution\n",
"mock_result = compute_census_matches(\n",
" canada_census_data=canada_census_data.mock,\n",
" italy_census_data=italy_census_data.mock\n",
" )\n",
" canada_census_data=canada_census_data.mock,\n",
" italy_census_data=italy_census_data.mock,\n",
")\n",
"mock_result"
]
},
Expand Down Expand Up @@ -659,14 +669,6 @@
"source": [
"assert result_ptr.syft_action_data == 813"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1beca4ac",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
16 changes: 4 additions & 12 deletions notebooks/tutorials/pandas-cookbook/01-reading-from-a-csv.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@
"new_project = sy.Project(\n",
" name=\"My pandas project 1\",\n",
" description=\"Hi, I would like to plot the Berri 1 column.\",\n",
" members=[guest_domain_client],\n",
" members=[guest_client],\n",
")\n",
"new_project"
]
Expand Down Expand Up @@ -538,7 +538,7 @@
},
"outputs": [],
"source": [
"project.create_code_request(get_column, guest_domain_client)"
"project.create_code_request(get_column, guest_client)"
]
},
{
Expand All @@ -550,7 +550,7 @@
},
"outputs": [],
"source": [
"assert len(guest_domain_client.code.get_all())==1"
"assert len(guest_client.code.get_all())==1"
]
},
{
Expand Down Expand Up @@ -821,14 +821,6 @@
"source": [
"node.land()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "32ab7e8e",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -847,7 +839,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.8"
"version": "3.11.5"
},
"toc": {
"base_numbering": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@
" \"X Coordinate (State Plane)\": lambda x: randint(1,1000000),\n",
" \"Y Coordinate (State Plane)\": lambda x: randint(1,1000000),\n",
" \"Complaint Type\": lambda x: random.choice([\"Illegal Parking\", \"Noise - Street/Sidewalk\", \"'Animal in a Park'\"]),\n",
" \"Descriptor\": lambda x: random.choice([ 'Branch or Limb Has Fallen Down','Branches Damaged','Broken Fence', 'Broken Glass']),\n",
" \"School Number\": lambda x: random.choice([ 'B073', 'B077', 'B079', 'B080-01', 'B087', 'B099', 'B100', 'B102', 'B109', 'B111']),\n",
" \"Bridge Highway Segment\": lambda x: random.choice([ 'Grand Central Pkwy (Exit 1 E-W)',\n",
" \"Descriptor\": lambda x: random.choice(['Branch or Limb Has Fallen Down','Branches Damaged','Broken Fence', 'Broken Glass']),\n",
" \"School Number\": lambda x: random.choice(['B073', 'B077', 'B079', 'B080-01', 'B087', 'B099', 'B100', 'B102', 'B109', 'B111']),\n",
" \"Bridge Highway Segment\": lambda x: random.choice(['Grand Central Pkwy (Exit 1 E-W)',\n",
" 'Grand Central Pkwy (Exit 10) - 69th Rd-Jewel Ave (Exit 11)',\n",
" 'GrandCentral Pkwy/VanWyck Expwy/College Point Blvd (Exit 22 A-E)',\n",
" 'Hamilton Ave (Exit 2A) - Gowanus Expwy (I-278) (Exit 1)',\n",
Expand Down Expand Up @@ -698,7 +698,7 @@
"new_project = sy.Project(\n",
" name=\"Pandas chapter 2\",\n",
" description=\"Hi, I would like to plot the histogram of the complaint types.\",\n",
" members=[guest_domain_client],\n",
" members=[guest_client],\n",
")\n",
"new_project"
]
Expand Down Expand Up @@ -726,7 +726,7 @@
},
"outputs": [],
"source": [
"project.create_code_request(get_counts, guest_domain_client)"
"project.create_code_request(get_counts, guest_client)"
]
},
{
Expand All @@ -738,7 +738,7 @@
},
"outputs": [],
"source": [
"assert len(guest_domain_client.code.get_all())==1"
"assert len(guest_client.code.get_all()) == 1"
]
},
{
Expand Down Expand Up @@ -974,14 +974,6 @@
"source": [
"node.land()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "247f8f48-7281-4dd5-a6fe-702ed46891cb",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@
"# Make the graphs a bit prettier, and bigger\n",
"plt.style.use('ggplot')\n",
"\n",
"# This is necessary to show lots of columns in pandas 0.12. \n",
"# This is necessary to show lots of columns in pandas 0.12.\n",
"# Not necessary in pandas 0.13.\n",
"pd.set_option('display.width', 5000) \n",
"pd.set_option('display.width', 5000)\n",
"pd.set_option('display.max_columns', 60)\n",
"\n",
"plt.rcParams['figure.figsize'] = (15, 5)"
Expand Down Expand Up @@ -222,9 +222,9 @@
" \"X Coordinate (State Plane)\": lambda x: randint(1,1000000),\n",
" \"Y Coordinate (State Plane)\": lambda x: randint(1,1000000),\n",
" \"Complaint Type\": lambda x: random.choice([\"Illegal Parking\", \"Noise - Street/Sidewalk\", \"'Animal in a Park'\"]),\n",
" \"Descriptor\": lambda x: random.choice([ 'Branch or Limb Has Fallen Down','Branches Damaged','Broken Fence', 'Broken Glass']),\n",
" \"School Number\": lambda x: random.choice([ 'B073', 'B077', 'B079', 'B080-01', 'B087', 'B099', 'B100', 'B102', 'B109', 'B111']),\n",
" \"Bridge Highway Segment\": lambda x: random.choice([ 'Grand Central Pkwy (Exit 1 E-W)',\n",
" \"Descriptor\": lambda x: random.choice(['Branch or Limb Has Fallen Down','Branches Damaged','Broken Fence', 'Broken Glass']),\n",
" \"School Number\": lambda x: random.choice(['B073', 'B077', 'B079', 'B080-01', 'B087', 'B099', 'B100', 'B102', 'B109', 'B111']),\n",
" \"Bridge Highway Segment\": lambda x: random.choice(['Grand Central Pkwy (Exit 1 E-W)',\n",
" 'Grand Central Pkwy (Exit 10) - 69th Rd-Jewel Ave (Exit 11)',\n",
" 'GrandCentral Pkwy/VanWyck Expwy/College Point Blvd (Exit 22 A-E)',\n",
" 'Hamilton Ave (Exit 2A) - Gowanus Expwy (I-278) (Exit 1)',\n",
Expand Down Expand Up @@ -265,7 +265,7 @@
"mock_data = dict()\n",
"for col in complaints.columns:\n",
" col_vals = complaints[col]\n",
" \n",
"\n",
" if col in fake_functions:\n",
" mock_func = fake_functions[col]\n",
" elif len(set(complaints[col])) < 100:\n",
Expand Down Expand Up @@ -810,7 +810,7 @@
"new_project = sy.Project(\n",
" name=\"Pandas chapter 3\",\n",
" description=\"Hi, I would like to plot the histogram of the noise complaint counts per area.\",\n",
" members=[guest_domain_client],\n",
" members=[guest_client],\n",
")\n",
"new_project"
]
Expand Down Expand Up @@ -838,7 +838,7 @@
},
"outputs": [],
"source": [
"project.create_code_request(get_counts, guest_domain_client)"
"project.create_code_request(get_counts, guest_client)"
]
},
{
Expand All @@ -850,7 +850,7 @@
},
"outputs": [],
"source": [
"assert len(guest_domain_client.code.get_all())==1"
"assert len(guest_client.code.get_all())==1"
]
},
{
Expand Down Expand Up @@ -1086,14 +1086,6 @@
"source": [
"node.land()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4374c6ed-b64f-4819-aca4-5570676d6c68",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -1112,7 +1104,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.8"
"version": "3.11.5"
},
"toc": {
"base_numbering": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@
"new_project = sy.Project(\n",
" name=\"Pandas Chapter 4\",\n",
" description=\"Hi, I would like to plot histogram of bikers per weekday\",\n",
" members=[guest_domain_client],\n",
" members=[guest_client],\n",
")\n",
"new_project"
]
Expand Down Expand Up @@ -616,7 +616,7 @@
},
"outputs": [],
"source": [
"project.create_code_request(get_bike_hist, guest_domain_client)"
"project.create_code_request(get_bike_hist, guest_client)"
]
},
{
Expand All @@ -628,7 +628,7 @@
},
"outputs": [],
"source": [
"assert len(guest_domain_client.code.get_all())==1"
"assert len(guest_client.code.get_all()) == 1"
]
},
{
Expand Down Expand Up @@ -876,14 +876,6 @@
"source": [
"node.land()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "cbcd55e5",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -902,7 +894,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.8"
"version": "3.11.5"
},
"toc": {
"base_numbering": 1,
Expand Down
Loading

0 comments on commit 1bae336

Please sign in to comment.