Skip to content

Commit

Permalink
[notebooks] add scale up+down tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yashgorana committed Feb 7, 2024
1 parent 370f876 commit 7793d4b
Showing 1 changed file with 94 additions and 1 deletion.
95 changes: 94 additions & 1 deletion notebooks/api/0.8/11-container-images-k8s.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@
"domain_client"
]
},
{
"cell_type": "markdown",
"id": "fe3d0aa7",
"metadata": {},
"source": [
"### Scaling Default Worker Pool"
]
},
{
"cell_type": "markdown",
"id": "55439eb5-1e92-46a6-a45a-471917a86265",
Expand All @@ -92,14 +100,99 @@
"domain_client.worker_pools"
]
},
{
"cell_type": "markdown",
"id": "0ff8e268",
"metadata": {},
"source": [
"Scale up to 3 workers"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "de9872be",
"metadata": {},
"outputs": [],
"source": [
"domain_client.api.services.worker_pool.scale(number=2, pool_name=\"default-pool\")"
"result = domain_client.api.services.worker_pool.scale(\n",
" number=3, pool_name=\"default-pool\"\n",
")\n",
"assert not isinstance(result, sy.SyftError), str(result)\n",
"result"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "da6a499b",
"metadata": {},
"outputs": [],
"source": [
"result = domain_client.api.services.worker_pool.get_by_name(pool_name=\"default-pool\")\n",
"assert len(result.workers) == 3, str(result.to_dict())\n",
"result"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "27761f0c",
"metadata": {},
"outputs": [],
"source": [
"# stdlib\n",
"# wait for some time for scale up to be ready\n",
"from time import sleep\n",
"\n",
"sleep(5)"
]
},
{
"cell_type": "markdown",
"id": "c1276b5c",
"metadata": {},
"source": [
"Scale down to 1 worker"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7f0aa94c",
"metadata": {},
"outputs": [],
"source": [
"default_worker_pool = domain_client.api.services.worker_pool.scale(\n",
" number=1, pool_name=\"default-pool\"\n",
")\n",
"assert not isinstance(result, sy.SyftError), str(result)\n",
"default_worker_pool"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "52acc6f6",
"metadata": {},
"outputs": [],
"source": [
"result = domain_client.api.services.worker_pool.get_by_name(pool_name=\"default-pool\")\n",
"assert len(result.workers) == 1, str(result.to_dict())\n",
"result"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9a7b40a3",
"metadata": {},
"outputs": [],
"source": [
"default_worker_pool = domain_client.api.services.worker_pool.get_by_name(\n",
" pool_name=\"default-pool\"\n",
")\n",
"default_worker_pool"
]
},
{
Expand Down

0 comments on commit 7793d4b

Please sign in to comment.