Skip to content

Commit

Permalink
generalized 11-container-images notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
rasswanth-s committed Feb 16, 2024
1 parent 2d2adae commit 8976cd2
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 8 deletions.
52 changes: 44 additions & 8 deletions notebooks/api/0.8/11-container-images-k8s.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
"# syft absolute\n",
"import syft as sy\n",
"\n",
"from getpass import getpass # noqa\n",
"\n",
"\n",
"sy.requires(SYFT_VERSION)\n",
"\n",
"# syft absolute\n",
Expand Down Expand Up @@ -210,11 +213,14 @@
"metadata": {},
"outputs": [],
"source": [
"registry = \"k3d-registry.localhost:5800\"\n",
"registry = os.getenv(\"SYFT_BASE_IMAGE_REGISTRY\", \"docker.io\")\n",
"repo = \"openmined/grid-backend\"\n",
"\n",
"res = requests.get(url=f\"http://{registry}/v2/{repo}/tags/list\")\n",
"tag = res.json()[\"tags\"][0]"
"if \"k3d\" in registry:\n",
" res = requests.get(url=f\"http://{registry}/v2/{repo}/tags/list\")\n",
" tag = res.json()[\"tags\"][0]\n",
"else:\n",
" tag = sy.__version__"
]
},
{
Expand Down Expand Up @@ -322,7 +328,23 @@
"id": "91a66871",
"metadata": {},
"source": [
"#### Add k3d Registry in Syft"
"#### Add External Registry in Syft"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "32a323ca-8293-408a-a878-a954df55d787",
"metadata": {},
"outputs": [],
"source": [
"external_registry = os.getenv(\"EXTERNAL_REGISTRY\", registry)\n",
"external_registry_username = os.getenv(\"EXTERNAL_REGISTRY_USERNAME\", None)\n",
"external_registry_password = os.getenv(\"EXTERNAL_REGISTRY_PASSWORD\", None)\n",
"\n",
"# external_registry = input()\n",
"# external_registry_username = getpass(\"Enter Registry Username\")\n",
"# external_registry_password = getpass(\"Enter Registry Password\")"
]
},
{
Expand All @@ -332,7 +354,7 @@
"metadata": {},
"outputs": [],
"source": [
"registry_add_result = domain_client.api.services.image_registry.add(registry)\n",
"registry_add_result = domain_client.api.services.image_registry.add(external_registry)\n",
"registry_add_result"
]
},
Expand Down Expand Up @@ -488,7 +510,11 @@
"outputs": [],
"source": [
"push_result = None\n",
"push_result = domain_client.api.services.worker_image.push(workerimage.id)\n",
"push_result = domain_client.api.services.worker_image.push(\n",
" workerimage.id,\n",
" username=external_registry_username,\n",
" password=external_registry_password,\n",
")\n",
"push_result"
]
},
Expand Down Expand Up @@ -544,6 +570,8 @@
" name=worker_pool_name,\n",
" image_uid=workerimage.id,\n",
" num_workers=3,\n",
" reg_username=external_registry_username,\n",
" reg_password=external_registry_password,\n",
")"
]
},
Expand Down Expand Up @@ -1027,7 +1055,11 @@
"source": [
"# Push OpenDP Image to registry\n",
"push_result = None\n",
"push_result = domain_client.api.services.worker_image.push(workerimage_opendp.id)\n",
"push_result = domain_client.api.services.worker_image.push(\n",
" workerimage_opendp.id,\n",
" username=external_registry_username,\n",
" password=external_registry_password,\n",
")\n",
"assert isinstance(push_result, sy.SyftSuccess), str(push_result)"
]
},
Expand All @@ -1043,6 +1075,8 @@
" pool_name=pool_name_opendp,\n",
" num_workers=3,\n",
" image_uid=workerimage_opendp.id,\n",
" reg_username=external_registry_username,\n",
" reg_password=external_registry_password,\n",
")\n",
"pool_create_request"
]
Expand Down Expand Up @@ -1210,7 +1244,9 @@
"metadata": {},
"outputs": [],
"source": [
"req_result = pool_image_create_request.approve()\n",
"req_result = pool_image_create_request.approve(\n",
" reg_username=external_registry_username, reg_password=external_registry_password\n",
")\n",
"req_result"
]
},
Expand Down
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@ setenv =
NODE_PORT = {env:NODE_PORT:9082}
GITHUB_CI = {env:GITHUB_CI:false}
PYTEST_MODULES = {env:PYTEST_MODULES:frontend container_workload}
SYFT_BASE_IMAGE_REGISTRY = {env:SYFT_BASE_IMAGE_REGISTRY:k3d-registry.localhost:5800}
commands =
bash -c "echo Running with GITHUB_CI=$GITHUB_CI; date"
python -c 'import syft as sy; sy.stage_protocol_changes()'
Expand Down Expand Up @@ -865,6 +866,7 @@ setenv =
NODE_URL = {env:NODE_URL:http://localhost}
EXCLUDE_NOTEBOOKS = {env:EXCLUDE_NOTEBOOKS:not 10-container-images.ipynb}
SYFT_VERSION = {env:SYFT_VERSION:local}
passenv=EXTERNAL_REGISTRY,EXTERNAL_REGISTRY_USERNAME,EXTERNAL_REGISTRY_PASSWORD
commands =
bash -c "echo Running with ORCHESTRA_DEPLOYMENT_TYPE=$ORCHESTRA_DEPLOYMENT_TYPE NODE_PORT=$NODE_PORT NODE_URL=$NODE_URL \
Excluding notebooks: $EXCLUDE_NOTEBOOKS SYFT_VERSION=$SYFT_VERSION; date"
Expand Down

0 comments on commit 8976cd2

Please sign in to comment.