Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions dagster_uc/manage_user_code_deployments.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def default(

def build_push_container(
deployment_name: str,
branch_name: str,
image_prefix: str | None,
config: UserCodeDeploymentsConfig,
use_sudo: bool,
Expand All @@ -105,7 +106,7 @@ def build_push_container(
dockerfile=config.dockerfile,
use_sudo=use_sudo,
tag=tag,
branch_name=deployment_name,
branch_name=branch_name,
use_az_login=config.use_az_login,
)

Expand Down Expand Up @@ -274,7 +275,7 @@ def deployment_delete(
name = handler.get_deployment_name(
deployment_name_suffix="",
use_project_name=config.use_project_name,
)
).full_name
else:
# In case the UI name separator of the deployment is passed
name = name.replace(":", "--")
Expand Down Expand Up @@ -308,7 +309,7 @@ def check_deployment(
) -> None:
"""This function executes before any other nested cli command is called and loads the configuration object."""
if not name:
name = handler.get_deployment_name(use_project_name=config.use_project_name)
name = handler.get_deployment_name(use_project_name=config.use_project_name).full_name
else:
# In case the UI name separator of the deployment is passed
name = name.replace(":", "--")
Expand All @@ -324,6 +325,8 @@ def check_deployment(
with contextlib.suppress(Exception):
for line in pod.logs(pretty=True, follow=True, timeout=timeout): # type: ignore
typer.echo(line)
if "started dagster code server" in line.lower():
break


@deployment_app.command(
Expand Down Expand Up @@ -400,10 +403,18 @@ def is_command_available(command: str) -> bool:
raise Exception("Podman installation is required to run dagster-uc.")

logger.debug("Using 'podman' to build image.")
deployment_name = deployment_name or handler.get_deployment_name(
deployment_name_suffix,
use_project_name=config.use_project_name,
)
if deployment_name:
(deployment_name, branch_name) = (deployment_name, deployment_name)
else:
dagster_deployment = handler.get_deployment_name(
deployment_name_suffix,
use_project_name=config.use_project_name,
)
(deployment_name, branch_name) = (
dagster_deployment.full_name,
dagster_deployment.branch_name,
)

logger.debug("Determining tag...")
new_tag = gen_tag(
deployment_name
Expand All @@ -420,9 +431,10 @@ def is_command_available(command: str) -> bool:
if not skip_build:
build_push_container(
deployment_name,
handler.config.image_prefix,
config,
use_sudo,
branch_name=branch_name,
image_prefix=handler.config.image_prefix,
config=config,
use_sudo=use_sudo,
tag=new_tag,
)

Expand Down
23 changes: 15 additions & 8 deletions dagster_uc/uc_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import re
import subprocess
from collections.abc import Callable
from typing import cast
from typing import NamedTuple, cast

import kr8s
import yaml
Expand All @@ -24,6 +24,13 @@
from dagster_uc.log import logger


class DagsterDeployment(NamedTuple):
"""Dagster deployment names"""

full_name: str
branch_name: str


class DagsterUserCodeHandler:
"""This the dagster-user code handler for common activities such as updating config maps, listing them and modifying them."""

Expand Down Expand Up @@ -423,7 +430,7 @@ def get_deployment_name( # noqa: D102
self,
deployment_name_suffix: str | None = None,
use_project_name: bool = True,
) -> str:
) -> DagsterDeployment:
"""Creates a deployment name based on the name of the pyproject.toml and name of git branch"""
logger.debug("Determining deployment name...")

Expand All @@ -437,12 +444,12 @@ def get_deployment_name( # noqa: D102
name = f"{project_name}--{branch}" if project_name is not None else branch

else:
name = (
f"{project_name}--{self.config.environment}"
if project_name is not None
else self.config.environment
)
return name
branch = self.config.environment
name = f"{project_name}--{branch}" if project_name is not None else branch
return DagsterDeployment(
full_name=name,
branch_name=branch,
)

def _ensure_dagster_version_match(self) -> None:
"""Raises an exception if the cluster version of dagster is different than the local version"""
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.3.0"
version = "0.3.1"
authors = [
{name = "Stefan Verbruggen"},
{name = "Ion Koutsouris"},
Expand Down
Loading