Skip to content

Commit

Permalink
Merge pull request #11 from ASML-Labs/fix/kr8s_breaking_change
Browse files Browse the repository at this point in the history
fix: convert generator to list
  • Loading branch information
ion-elgreco authored Jan 13, 2025
2 parents 09c222a + ad97920 commit 81abeb3
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 36 deletions.
16 changes: 9 additions & 7 deletions dagster_uc/manage_user_code_deployments.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

import kr8s
import typer
from kr8s._objects import APIObject
from kr8s.objects import (
APIObject,
ConfigMap,
Pod,
)
Expand Down Expand Up @@ -459,12 +459,14 @@ def is_command_available(command: str) -> bool:
timeout = 40 if not full_redeploy_done else 240

while True:
code_pods = cast(
list[APIObject],
handler.api.get(
Pod,
label_selector=f"deployment={deployment_name}",
namespace=config.namespace,
code_pods = list(
cast(
list[APIObject],
handler.api.get(
Pod,
label_selector=f"deployment={deployment_name}",
namespace=config.namespace,
),
),
)
if len(code_pods) == 0:
Expand Down
68 changes: 41 additions & 27 deletions dagster_uc/uc_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,9 +434,15 @@ def _ensure_dagster_version_match(self) -> None:
local_dagster_version = Version(self.config.dagster_version)

## GETS cluster version from dagster deamon pod
deamon_pod = cast(
list[Pod],
self.api.get(Pod, label_selector="deployment=daemon", namespace=self.config.namespace),
deamon_pod = list(
cast(
list[Pod],
self.api.get(
Pod,
label_selector="deployment=daemon",
namespace=self.config.namespace,
),
),
)[0]

ex = deamon_pod.exec(command=["dagster", "--version"])
Expand All @@ -458,12 +464,14 @@ def _ensure_dagster_version_match(self) -> None:

def check_if_code_pod_exists(self, label: str) -> bool:
"""Checks if the code location pod of specific label is available"""
running_pods = cast(
list[APIObject],
self.api.get(
Pod,
label_selector=f"deployment={label}",
namespace=self.config.namespace,
running_pods = list(
cast(
list[APIObject],
self.api.get(
Pod,
label_selector=f"deployment={label}",
namespace=self.config.namespace,
),
),
)
return len(running_pods) > 0
Expand Down Expand Up @@ -495,23 +503,27 @@ def delete_k8s_resources(self, label_selector: str):
def acquire_semaphore(self, reset_lock: bool = False) -> bool:
"""Acquires a semaphore by creating a configmap"""
if reset_lock:
semaphore_list = cast(
list[APIObject],
self.api.get(
ConfigMap,
self.config.uc_deployment_semaphore_name,
namespace=self.config.namespace,
semaphore_list = list(
cast(
list[APIObject],
self.api.get(
ConfigMap,
self.config.uc_deployment_semaphore_name,
namespace=self.config.namespace,
),
),
)
if len(semaphore_list):
semaphore_list[0].delete() # type: ignore

semaphore_list = cast(
list[ConfigMap],
self.api.get(
ConfigMap,
self.config.uc_deployment_semaphore_name,
namespace=self.config.namespace,
semaphore_list = list(
cast(
list[ConfigMap],
self.api.get(
ConfigMap,
self.config.uc_deployment_semaphore_name,
namespace=self.config.namespace,
),
),
)
if len(semaphore_list):
Expand All @@ -537,12 +549,14 @@ def acquire_semaphore(self, reset_lock: bool = False) -> bool:
def release_semaphore(self) -> None:
"""Releases the semaphore lock"""
try:
semaphore = cast(
list[ConfigMap],
self.api.get(
ConfigMap,
self.config.uc_deployment_semaphore_name,
namespace=self.config.namespace,
semaphore = list(
cast(
list[ConfigMap],
self.api.get(
ConfigMap,
self.config.uc_deployment_semaphore_name,
namespace=self.config.namespace,
),
),
)[0]
semaphore.patch({"data": {"locked": "false"}}) # type: ignore
Expand Down
2 changes: 1 addition & 1 deletion dagster_uc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def gen_tag(
tags_ints = [int(tag) for tag in tags]
if not len(tags_ints):
return f"{dagster_version}-0"
new_tag = f"{dagster_version}-{max(tags_ints)+1}"
new_tag = f"{dagster_version}-{max(tags_ints) + 1}"
return new_tag


Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "dagster-uc"
version = "0.2.3"
version = "0.2.4"
authors = [
{name = "Stefan Verbruggen"},
{name = "Ion Koutsouris"},
Expand Down

0 comments on commit 81abeb3

Please sign in to comment.