diff --git a/zetta_utils/cloud_management/resource_allocation/k8s/configmap.py b/zetta_utils/cloud_management/resource_allocation/k8s/configmap.py index 35fc6c40b..79a127bc2 100644 --- a/zetta_utils/cloud_management/resource_allocation/k8s/configmap.py +++ b/zetta_utils/cloud_management/resource_allocation/k8s/configmap.py @@ -25,6 +25,7 @@ def get_configmap( labels: Optional[Dict] = None, data: Optional[Dict[str, str]] = None, ): + name = f"run-{name}" meta = k8s_client.V1ObjectMeta(annotations=annotations, labels=labels, name=name) return k8s_client.V1ConfigMap(metadata=meta, data=data) diff --git a/zetta_utils/cloud_management/resource_allocation/k8s/deployment.py b/zetta_utils/cloud_management/resource_allocation/k8s/deployment.py index 923cce326..3f6204efb 100644 --- a/zetta_utils/cloud_management/resource_allocation/k8s/deployment.py +++ b/zetta_utils/cloud_management/resource_allocation/k8s/deployment.py @@ -38,6 +38,7 @@ def get_deployment_spec( resource_requests: Optional[Dict[str, int | float | str]] = None, provisioning_model: Literal["standard", "spot"] = "spot", ) -> k8s_client.V1Deployment: + name = f"run-{name}" schedule_toleration = k8s_client.V1Toleration( key="worker-pool", operator="Equal", value="true", effect="NoSchedule" ) @@ -128,6 +129,7 @@ def get_deployment( labels: Optional[Dict[str, str]] = None, revision_history_limit: Optional[int] = 10, ) -> k8s_client.V1Deployment: + name = f"run-{name}" labels = labels or {"app": name} pod_template = k8s_client.V1PodTemplateSpec( metadata=k8s_client.V1ObjectMeta(labels=labels), diff --git a/zetta_utils/cloud_management/resource_allocation/k8s/job.py b/zetta_utils/cloud_management/resource_allocation/k8s/job.py index 4b8ea63d1..0ab1af1cf 100644 --- a/zetta_utils/cloud_management/resource_allocation/k8s/job.py +++ b/zetta_utils/cloud_management/resource_allocation/k8s/job.py @@ -60,6 +60,7 @@ def get_job_template( selector: Optional[k8s_client.V1LabelSelector] = None, suspend: Optional[bool] = False, ) -> k8s_client.V1JobTemplateSpec: + name = f"run-{name}" meta = k8s_client.V1ObjectMeta(name=name, labels=labels) job_spec = _get_job_spec( pod_spec=pod_spec, @@ -83,6 +84,7 @@ def get_job( selector: Optional[k8s_client.V1LabelSelector] = None, suspend: Optional[bool] = False, ) -> k8s_client.V1Job: + name = f"run-{name}" meta = k8s_client.V1ObjectMeta(name=name, labels=labels) job_spec = _get_job_spec( pod_spec=pod_spec, diff --git a/zetta_utils/cloud_management/resource_allocation/k8s/pod.py b/zetta_utils/cloud_management/resource_allocation/k8s/pod.py index f75d548da..b1292d46f 100644 --- a/zetta_utils/cloud_management/resource_allocation/k8s/pod.py +++ b/zetta_utils/cloud_management/resource_allocation/k8s/pod.py @@ -34,7 +34,7 @@ def get_pod_spec( volume_mounts: Optional[List[k8s_client.V1VolumeMount]] = None, resource_requests: Optional[Dict[str, int | float | str]] = None, ) -> k8s_client.V1PodSpec: - + name = f"run-{name}" envs = envs or [] host_aliases = host_aliases or [] tolerations = tolerations or [] diff --git a/zetta_utils/cloud_management/resource_allocation/k8s/secret.py b/zetta_utils/cloud_management/resource_allocation/k8s/secret.py index 89ef64fdb..011c6e6b4 100644 --- a/zetta_utils/cloud_management/resource_allocation/k8s/secret.py +++ b/zetta_utils/cloud_management/resource_allocation/k8s/secret.py @@ -70,7 +70,7 @@ def get_secrets_and_mapping( raise ValueError( f"Please set `{env_k}` environment variable in order to create a deployment." ) - secret_name = f"{run_id}-{env_k}".lower().replace("_", "-") + secret_name = f"run-{run_id}-{env_k}".lower().replace("_", "-") env_secret_mapping[env_k] = secret_name secrets_kv[secret_name] = env_v diff --git a/zetta_utils/cloud_management/resource_allocation/k8s/service.py b/zetta_utils/cloud_management/resource_allocation/k8s/service.py index 80f135fb7..7da6b86f8 100644 --- a/zetta_utils/cloud_management/resource_allocation/k8s/service.py +++ b/zetta_utils/cloud_management/resource_allocation/k8s/service.py @@ -27,6 +27,7 @@ def get_service( selector: Optional[Dict[str, str]] = None, service_type: Optional[str] = None, ): + name = f"run-{name}" meta = k8s_client.V1ObjectMeta(annotations=annotations, labels=labels, name=name) service_spec = k8s_client.V1ServiceSpec(ports=ports, selector=selector, type=service_type) return k8s_client.V1Service(metadata=meta, spec=service_spec) diff --git a/zetta_utils/mazepa_addons/configurations/execute_on_gcp_with_sqs.py b/zetta_utils/mazepa_addons/configurations/execute_on_gcp_with_sqs.py index f97881519..3ef720e2c 100644 --- a/zetta_utils/mazepa_addons/configurations/execute_on_gcp_with_sqs.py +++ b/zetta_utils/mazepa_addons/configurations/execute_on_gcp_with_sqs.py @@ -64,8 +64,8 @@ def get_gcp_with_sqs_config( semaphores_spec: dict[SemaphoreType, int] | None = None, provisioning_model: Literal["standard", "spot"] = "spot", ) -> tuple[PushMessageQueue[Task], PullMessageQueue[OutcomeReport], list[AbstractContextManager]]: - work_queue_name = f"zzz-{execution_id}-work" - outcome_queue_name = f"zzz-{execution_id}-outcome" + work_queue_name = f"run-{execution_id}-work" + outcome_queue_name = f"run-{execution_id}-outcome" task_queue_spec = { "@type": "SQSQueue", diff --git a/zetta_utils/mazepa_addons/configurations/execute_on_slurm.py b/zetta_utils/mazepa_addons/configurations/execute_on_slurm.py index 40c51d9b1..bca855ad1 100644 --- a/zetta_utils/mazepa_addons/configurations/execute_on_slurm.py +++ b/zetta_utils/mazepa_addons/configurations/execute_on_slurm.py @@ -134,8 +134,8 @@ def get_slurm_contex_managers( semaphores_spec: dict[SemaphoreType, int] | None, message_queue: Literal["sqs", "fq"], ) -> tuple[PushMessageQueue[Task], PullMessageQueue[OutcomeReport], list[AbstractContextManager]]: - work_queue_name = f"zzz-{execution_id}-work" - outcome_queue_name = f"zzz-{execution_id}-outcome" + work_queue_name = f"run-{execution_id}-work" + outcome_queue_name = f"run-{execution_id}-outcome" if message_queue == "fq": task_queue_spec = { diff --git a/zetta_utils/run/resource.py b/zetta_utils/run/resource.py index 42c1a381d..b84ee4da5 100644 --- a/zetta_utils/run/resource.py +++ b/zetta_utils/run/resource.py @@ -38,8 +38,6 @@ class Resource: def register_resource(resource: Resource) -> str: _resource = attrs.asdict(resource) - resource_name = _resource.get("name", "") - _resource["name"] = f"run-{resource_name}" row_key = str(uuid.uuid4()) col_keys = tuple(_resource.keys()) RESOURCE_DB[(row_key, col_keys)] = _resource