Skip to content

Commit

Permalink
feat(config): add get_dask_component_names function (reanahub#478)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alputer committed Nov 21, 2024
1 parent 2caa2e2 commit a47aa21
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions reana_commons/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,23 @@ def build_unique_component_name(component_type, id=None):
)


def get_dask_component_name(workflow_id, name_type):
"""Generate the name of a Dask-related object based on the workflow ID and name type."""
name_map = {
"cluster": f"reana-dask-{workflow_id}",
"autoscaler": f"dask-autoscaler-{workflow_id}",
"dashboard_ingress": f"dask-dashboard-ingress-{workflow_id}",
"dashboard_service": f"reana-dask-{workflow_id}-scheduler",
"dashboard_ingress_middleware": f"dask-dashboard-ingress-{workflow_id}-replacepath",
"db_service": f"dask-service-{workflow_id}",
}
if name_type not in name_map:
raise ValueError(
f"Invalid name type: '{name_type}'. Valid types are: {', '.join(name_map.keys())}."
)
return name_map[name_type]


def get_usage_percentage(usage: int, limit: int) -> str:
"""Usage percentage."""
if limit == 0:
Expand Down

0 comments on commit a47aa21

Please sign in to comment.