Skip to content

Commit

Permalink
Merge branch 'dev' into eelco/generic-linkedobj
Browse files Browse the repository at this point in the history
  • Loading branch information
eelcovdw authored Sep 27, 2024
2 parents 8c2691b + 3384ae0 commit ff2ff6e
Show file tree
Hide file tree
Showing 74 changed files with 2,238 additions and 2,526 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/pr-tests-syft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,10 @@ jobs:
max-parallel: 99
matrix:
# Disable on windows until its flakyness is reduced.
# Also disable on macos for now since SMTP server
# fails to write to emails.json in CI runner.
# os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest]
python-version: ["3.12"]
deployment-type: ["python"]
bump-version: ["False"]
Expand Down
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,11 @@ packages/grid/helm/examples/dev/migration.yaml
# dynaconf settings file
**/settings.yaml


# Any temporary material created for scenarios
notebooks/scenarios/bigquery/*.json

notebooks/scenarios/bigquery/sync/*.json
notebooks/scenarios/bigquery/sync/*.json.lock
notebooks/tutorials/version-upgrades/*.yaml
notebooks/tutorials/version-upgrades/*.blob

notebooks/scenarios/bigquery/sync/emails.json
4 changes: 2 additions & 2 deletions notebooks/scenarios/bigquery/010-setup-bigquery-pool.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "syft",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -536,7 +536,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
"version": "3.12.5"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions notebooks/scenarios/bigquery/020-configure-api.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
" description=\"This endpoint allows to query Bigquery storage via SQL queries.\",\n",
" private_function=private_func,\n",
" mock_function=mock_func,\n",
" worker_pool=this_worker_pool_name,\n",
" worker_pool_name=this_worker_pool_name,\n",
")\n",
"\n",
"high_client.custom_api.add(endpoint=new_endpoint)"
Expand Down Expand Up @@ -376,7 +376,7 @@
" settings={\n",
" \"calls_per_min\": 5,\n",
" },\n",
" worker_pool=this_worker_pool_name,\n",
" worker_pool_name=this_worker_pool_name,\n",
")"
]
},
Expand Down Expand Up @@ -431,7 +431,7 @@
"outputs": [],
"source": [
"submit_query_function = make_submit_query(\n",
" settings={}, worker_pool=this_worker_pool_name\n",
" settings={}, worker_pool_name=this_worker_pool_name\n",
")"
]
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# stdlib\n",
"from os import environ as env\n",
"\n",
"# syft absolute\n",
"import syft as sy\n",
"from syft.util.test_helpers.email_helpers import get_email_server"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# stdlib\n",
"environment = env.get(\"ORCHESTRA_DEPLOYMENT_TYPE\", \"python\")\n",
"high_port = env.get(\"CLUSTER_HTTP_PORT_HIGH\", \"9081\")\n",
"low_port = env.get(\"CLUSTER_HTTP_PORT_LOW\", \"9083\")\n",
"print(environment, high_port, low_port)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# when in k8s these are the default values\n",
"ROOT_EMAIL = \"[email protected]\"\n",
"ROOT_PASSWORD = \"bqpw\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# in case we are not in k8s we set them here for orchestra to use\n",
"env[\"DEFAULT_ROOT_EMAIL\"] = ROOT_EMAIL\n",
"env[\"DEFAULT_ROOT_PASSWORD\"] = ROOT_PASSWORD"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"server_low = sy.orchestra.launch(\n",
" name=\"bigquery-low\",\n",
" server_side_type=\"low\",\n",
" dev_mode=True,\n",
" reset=True,\n",
" n_consumers=1,\n",
" create_producer=True,\n",
" port=low_port,\n",
")\n",
"\n",
"server_high = sy.orchestra.launch(\n",
" name=\"bigquery-high\",\n",
" server_side_type=\"high\",\n",
" dev_mode=True,\n",
" reset=True,\n",
" n_consumers=1,\n",
" create_producer=True,\n",
" port=high_port,\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"email_server, smtp_server = get_email_server(reset=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"root_client_low = sy.login(\n",
" url=f\"http://localhost:{low_port}\", email=ROOT_EMAIL, password=ROOT_PASSWORD\n",
")\n",
"root_client_high = sy.login(\n",
" url=f\"http://localhost:{high_port}\", email=ROOT_EMAIL, password=ROOT_PASSWORD\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Create new admin client"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ADMIN_EMAIL, ADMIN_PW = \"[email protected]\", \"bqpw2\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# create admin account on low side\n",
"root_client_low.register(\n",
" name=\"second admin\", email=ADMIN_EMAIL, password=ADMIN_PW, password_verify=ADMIN_PW\n",
")\n",
"# update role\n",
"new_user_id = root_client_low.users.search(email=ADMIN_EMAIL)[0].id\n",
"root_client_low.users.update(uid=new_user_id, role=\"admin\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# create admin account on high side\n",
"root_client_high.register(\n",
" name=\"second admin\", email=ADMIN_EMAIL, password=ADMIN_PW, password_verify=ADMIN_PW\n",
")\n",
"# update role\n",
"new_user_id = root_client_high.users.search(email=ADMIN_EMAIL)[0].id\n",
"root_client_high.users.update(uid=new_user_id, role=\"admin\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# We cannot delete the root client"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"low_client = sy.login(\n",
" url=f\"http://localhost:{low_port}\", email=ADMIN_EMAIL, password=ADMIN_PW\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"root_admin_id = low_client.users.search(email=ROOT_EMAIL)[0].id"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"with sy.raises(sy.SyftException):\n",
" low_client.users.delete(root_admin_id)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Create ephemeral admin and delete it"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# register 2nd new admin (to delete)\n",
"user_email, user_pw = \"[email protected]\", \"bqpw3\"\n",
"## create\n",
"root_client_low.register(\n",
" name=\"x\", email=user_email, password=user_pw, password_verify=user_pw\n",
")\n",
"## update role\n",
"new_user_id2 = root_client_low.users.search(email=user_email)[0].id\n",
"root_client_low.users.update(uid=new_user_id2, role=\"admin\")\n",
"\n",
"# delete\n",
"root_client_low.users.delete(new_user_id2)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Cleanup"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"if environment != \"remote\":\n",
" server_high.land()\n",
" server_low.land()\n",
"smtp_server.stop()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.5"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Loading

0 comments on commit ff2ff6e

Please sign in to comment.