Skip to content

Commit

Permalink
Rename reg_username, reg_password to registry_...
Browse files Browse the repository at this point in the history
to avoid ambiguity
  • Loading branch information
kiendang committed May 30, 2024
1 parent 2b11bf2 commit 1935f52
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 44 deletions.
10 changes: 6 additions & 4 deletions notebooks/api/0.8/11-container-images-k8s.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -570,8 +570,8 @@
" pool_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",
" registry_username=external_registry_username,\n",
" registry_password=external_registry_password,\n",
")"
]
},
Expand Down Expand Up @@ -1097,7 +1097,8 @@
"source": [
"# get the pending request and approve it\n",
"req_result = pool_create_request.approve(\n",
" reg_username=external_registry_username, reg_password=external_registry_password\n",
" registry_username=external_registry_username,\n",
" registry_password=external_registry_password,\n",
")\n",
"req_result"
]
Expand Down Expand Up @@ -1243,7 +1244,8 @@
"outputs": [],
"source": [
"req_result = pool_image_create_request.approve(\n",
" reg_username=external_registry_username, reg_password=external_registry_password\n",
" registry_username=external_registry_username,\n",
" registry_password=external_registry_password,\n",
")\n",
"req_result"
]
Expand Down
16 changes: 8 additions & 8 deletions packages/syft/src/syft/custom_worker/runner_k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ def create_pool(
replicas: int = 1,
env_vars: list[dict] | None = None,
mount_secrets: dict | None = None,
reg_username: str | None = None,
reg_password: str | None = None,
registry_username: str | None = None,
registry_password: str | None = None,
reg_url: str | None = None,
**kwargs: Any,
) -> StatefulSet:
try:
# create pull secret if registry credentials are passed
pull_secret = None
if reg_username and reg_password and reg_url:
if registry_username and registry_password and reg_url:
pull_secret = self._create_image_pull_secret(
pool_name,
reg_username,
reg_password,
registry_username,
registry_password,
reg_url,
)

Expand Down Expand Up @@ -126,16 +126,16 @@ def get_pod_env_vars(self, pod: str | Pod) -> list[dict] | None:
def _create_image_pull_secret(
self,
pool_name: str,
reg_username: str,
reg_password: str,
registry_username: str,
registry_password: str,
reg_url: str,
**kwargs: Any,
) -> Secret:
return KubeUtils.create_dockerconfig_secret(
secret_name=f"pull-secret-{pool_name}",
component=pool_name,
registries=[
(reg_url, reg_username, reg_password),
(reg_url, registry_username, registry_password),
],
)

Expand Down
8 changes: 4 additions & 4 deletions packages/syft/src/syft/service/request/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ def _run(
push_result = worker_image_service.push(
service_context,
image_uid=worker_image.id,
username=context.extra_kwargs.get("reg_username", None),
password=context.extra_kwargs.get("reg_password", None),
username=context.extra_kwargs.get("registry_username", None),
password=context.extra_kwargs.get("registry_password", None),
)

if isinstance(push_result, SyftError):
Expand Down Expand Up @@ -335,8 +335,8 @@ def _run(
pool_name=self.pool_name,
image_uid=self.image_uid,
num_workers=self.num_workers,
reg_username=context.extra_kwargs.get("reg_username", None),
reg_password=context.extra_kwargs.get("reg_password", None),
registry_username=context.extra_kwargs.get("registry_username", None),
registry_password=context.extra_kwargs.get("registry_password", None),
)
if isinstance(result, SyftError):
return Err(result)
Expand Down
28 changes: 14 additions & 14 deletions packages/syft/src/syft/service/worker/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ def create_kubernetes_pool(
replicas: int,
queue_port: int,
debug: bool,
reg_username: str | None = None,
reg_password: str | None = None,
registry_username: str | None = None,
registry_password: str | None = None,
reg_url: str | None = None,
**kwargs: Any,
) -> list[Pod] | SyftError:
Expand Down Expand Up @@ -360,8 +360,8 @@ def create_kubernetes_pool(
replicas=replicas,
env_vars=env_vars,
mount_secrets=mount_secrets,
reg_username=reg_username,
reg_password=reg_password,
registry_username=registry_username,
registry_password=registry_password,
reg_url=reg_url,
)
except Exception as e:
Expand Down Expand Up @@ -402,8 +402,8 @@ def run_workers_in_kubernetes(
queue_port: int,
start_idx: int = 0,
debug: bool = False,
reg_username: str | None = None,
reg_password: str | None = None,
registry_username: str | None = None,
registry_password: str | None = None,
reg_url: str | None = None,
**kwargs: Any,
) -> list[ContainerSpawnStatus] | SyftError:
Expand All @@ -419,8 +419,8 @@ def run_workers_in_kubernetes(
replicas=worker_count,
queue_port=queue_port,
debug=debug,
reg_username=reg_username,
reg_password=reg_password,
registry_username=registry_username,
registry_password=registry_password,
reg_url=reg_url,
)
else:
Expand Down Expand Up @@ -501,8 +501,8 @@ def run_containers(
queue_port: int,
dev_mode: bool = False,
start_idx: int = 0,
reg_username: str | None = None,
reg_password: str | None = None,
registry_username: str | None = None,
registry_password: str | None = None,
reg_url: str | None = None,
) -> list[ContainerSpawnStatus] | SyftError:
results = []
Expand All @@ -524,8 +524,8 @@ def run_containers(
pool_name=pool_name,
queue_port=queue_port,
debug=dev_mode,
username=reg_username,
password=reg_password,
username=registry_username,
password=registry_password,
registry_url=reg_url,
)
results.append(spawn_result)
Expand All @@ -537,8 +537,8 @@ def run_containers(
queue_port=queue_port,
debug=dev_mode,
start_idx=start_idx,
reg_username=reg_username,
reg_password=reg_password,
registry_username=registry_username,
registry_password=registry_password,
reg_url=reg_url,
)

Expand Down
28 changes: 14 additions & 14 deletions packages/syft/src/syft/service/worker/worker_pool_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ def launch(
pool_name: str,
image_uid: UID | None,
num_workers: int,
reg_username: str | None = None,
reg_password: str | None = None,
registry_username: str | None = None,
registry_password: str | None = None,
) -> list[ContainerSpawnStatus] | SyftError:
"""Creates a pool of workers from the given SyftWorkerImage.
Expand Down Expand Up @@ -126,8 +126,8 @@ def launch(
worker_cnt=num_workers,
worker_image=worker_image,
worker_stash=worker_stash,
reg_username=reg_username,
reg_password=reg_password,
registry_username=registry_username,
registry_password=registry_password,
)

if isinstance(result, SyftError):
Expand Down Expand Up @@ -366,8 +366,8 @@ def add_workers(
number: int,
pool_id: UID | None = None,
pool_name: str | None = None,
reg_username: str | None = None,
reg_password: str | None = None,
registry_username: str | None = None,
registry_password: str | None = None,
) -> list[ContainerSpawnStatus] | SyftError:
"""Add workers to existing worker pool.
Expand Down Expand Up @@ -425,8 +425,8 @@ def add_workers(
worker_cnt=number,
worker_image=worker_image,
worker_stash=worker_stash,
reg_username=reg_username,
reg_password=reg_password,
registry_username=registry_username,
registry_password=registry_password,
)

if isinstance(result, SyftError):
Expand Down Expand Up @@ -487,8 +487,8 @@ def scale(
pool_id=pool_id,
pool_name=pool_name,
# kube scaling doesn't require password as it replicates an existing deployment
reg_username=None,
reg_password=None,
registry_username=None,
registry_password=None,
)
if isinstance(result, SyftError):
return result
Expand Down Expand Up @@ -656,8 +656,8 @@ def _create_workers_in_pool(
worker_cnt: int,
worker_image: SyftWorkerImage,
worker_stash: WorkerStash,
reg_username: str | None = None,
reg_password: str | None = None,
registry_username: str | None = None,
registry_password: str | None = None,
) -> tuple[list[LinkedObject], list[ContainerSpawnStatus]] | SyftError:
queue_port = context.node.queue_config.client_config.queue_port

Expand Down Expand Up @@ -686,8 +686,8 @@ def _create_workers_in_pool(
orchestration=get_orchestration_type(),
queue_port=queue_port,
dev_mode=context.node.dev_mode,
reg_username=reg_username,
reg_password=reg_password,
registry_username=registry_username,
registry_password=registry_password,
reg_url=registry_host,
)
if isinstance(result, SyftError):
Expand Down

0 comments on commit 1935f52

Please sign in to comment.