Skip to content

Commit

Permalink
Rename arg name to pool_name in worker_pool_service.launch
Browse files Browse the repository at this point in the history
to be consistent with other endpoints
  • Loading branch information
kiendang committed May 24, 2024
1 parent 31c6e78 commit a7be81e
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion notebooks/admin/Custom API + Custom Worker.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
"source": [
"worker_pool_name = \"bigquery-pool\"\n",
"domain_client.api.services.worker_pool.launch(\n",
" name=worker_pool_name,\n",
" pool_name=worker_pool_name,\n",
" image_uid=workerimage.id,\n",
" num_workers=1,\n",
")"
Expand Down
2 changes: 1 addition & 1 deletion notebooks/api/0.8/10-container-images.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@
"source": [
"worker_pool_name = \"opendp-pool\"\n",
"worker_pool_res = domain_client.api.services.worker_pool.launch(\n",
" name=worker_pool_name,\n",
" pool_name=worker_pool_name,\n",
" image_uid=workerimage.id,\n",
" num_workers=2,\n",
")"
Expand Down
2 changes: 1 addition & 1 deletion notebooks/api/0.8/11-container-images-k8s.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@
"source": [
"worker_pool_name = \"custom-pool\"\n",
"worker_pool_res = domain_client.api.services.worker_pool.launch(\n",
" name=worker_pool_name,\n",
" pool_name=worker_pool_name,\n",
" image_uid=workerimage.id,\n",
" num_workers=3,\n",
" reg_username=external_registry_username,\n",
Expand Down
2 changes: 1 addition & 1 deletion packages/syft/src/syft/node/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -1749,7 +1749,7 @@ def create_default_worker_pool(node: Node) -> SyftError | None:
create_pool_method = node.get_service_method(SyftWorkerPoolService.launch)
result = create_pool_method(
context,
name=default_pool_name,
pool_name=default_pool_name,
image_uid=default_image.id,
num_workers=worker_count,
)
Expand Down
2 changes: 1 addition & 1 deletion packages/syft/src/syft/service/request/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def _run(

result = worker_pool_service.launch(
context=service_context,
name=self.pool_name,
pool_name=self.pool_name,
image_uid=self.image_uid,
num_workers=self.num_workers,
reg_username=context.extra_kwargs.get("reg_username", None),
Expand Down
12 changes: 7 additions & 5 deletions packages/syft/src/syft/service/worker/worker_pool_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def __init__(self, store: DocumentStore) -> None:
def launch(
self,
context: AuthedServiceContext,
name: str,
pool_name: str,
image_uid: UID | None,
num_workers: int,
reg_username: str | None = None,
Expand All @@ -83,13 +83,15 @@ def launch(
num_workers (int): the number of SyftWorker that needs to be created in the pool
"""

result = self.stash.get_by_name(context.credentials, pool_name=name)
result = self.stash.get_by_name(context.credentials, pool_name=pool_name)

if result.is_err():
return SyftError(message=f"{result.err()}")

if result.ok() is not None:
return SyftError(message=f"Worker Pool with name: {name} already exists !!")
return SyftError(
message=f"Worker Pool with name: {pool_name} already exists !!"
)

# If image uid is not passed, then use the default worker image
# to create the worker pool
Expand Down Expand Up @@ -118,7 +120,7 @@ def launch(
# and with the desired number of workers
result = _create_workers_in_pool(
context=context,
pool_name=name,
pool_name=pool_name,
existing_worker_cnt=0,
worker_cnt=num_workers,
worker_image=worker_image,
Expand All @@ -134,7 +136,7 @@ def launch(

# Update the Database with the pool information
worker_pool = WorkerPool(
name=name,
name=pool_name,
max_count=num_workers,
image_id=worker_image.id,
worker_list=worker_list,
Expand Down
2 changes: 1 addition & 1 deletion packages/syft/tests/syft/worker_pool/worker_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_syft_worker(worker: Worker):
pool_name = "custom-worker-pool"
num_workers = 3
worker_pool_res = root_client.api.services.worker_pool.launch(
name=pool_name,
pool_name=pool_name,
image_uid=worker_image.id,
num_workers=num_workers,
)
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/container_workload/pool_image_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def test_pool_launch(domain_1_port, external_registry_uid) -> None:
# Launch a worker pool
worker_pool_name = "custom-worker-pool-opendp"
worker_pool_res = domain_client.api.services.worker_pool.launch(
name=worker_pool_name,
pool_name=worker_pool_name,
image_uid=worker_image.id,
num_workers=3,
)
Expand Down

0 comments on commit a7be81e

Please sign in to comment.