Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(config): add get_dask_component_names function #478

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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
Loading