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
25 changes: 19 additions & 6 deletions dagster_uc/manage_user_code_deployments.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,27 +255,40 @@ def deployment_delete(
),
] = False,
name: Annotated[
str,
str | None,
typer.Option(
"--name",
"-n",
help="The name of the deployment to delete. If none is provided, the deployment corresponding to the currently checked out git branch will be deleted.",
),
] = "",
] = None,
branch: Annotated[
str | None,
typer.Option(
"--branch",
"-b",
help="Can be the branch name as-is, this will be converted to a dagster-uc compatible deployment name.",
),
] = None,
) -> None:
if delete_all:
handler.remove_all_deployments()
handler.deploy_to_k8s(reload_dagster=True)
typer.echo("\033[1mDeleted all deployments\033[0m")
else:
if not name:
if name is not None:
# In case the UI name separator of the deployment is passed
name = name.replace(":", "--")
elif branch is not None:
name = handler.get_deployment_name(
deployment_name_suffix="",
use_project_name=config.use_project_name,
branch=branch,
).full_name
else:
# In case the UI name separator of the deployment is passed
name = name.replace(":", "--")
name = handler.get_deployment_name(
use_project_name=config.use_project_name,
).full_name

handler.remove_user_deployment_from_configmap(name)
handler.deploy_to_k8s(reload_dagster=True)
typer.echo(f"Deleted deployment \033[1m{name}\033[0m")
Expand Down
6 changes: 5 additions & 1 deletion dagster_uc/uc_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,14 +421,18 @@ def get_deployment_name( # noqa: D102
self,
deployment_name_suffix: str | None = None,
use_project_name: bool = True,
branch: str | None = None,
) -> DagsterDeployment:
"""Creates a deployment name based on the name of the pyproject.toml and name of git branch"""
logger.debug("Determining deployment name...")

project_name = self._get_project_name() if use_project_name else None

if not self.config.cicd:
branch = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"]).decode()
if branch is None:
branch = subprocess.check_output(
["git", "rev-parse", "--abbrev-ref", "HEAD"],
).decode()
if deployment_name_suffix:
branch += deployment_name_suffix
branch = re.sub(r"[^a-zA-Z0-9]+", "-", branch).strip("-") # Strips double --
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.5.1"
version = "0.5.2"
authors = [
{name = "Stefan Verbruggen"},
{name = "Ion Koutsouris"},
Expand Down
Loading