Skip to content
Open
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
2 changes: 1 addition & 1 deletion ansible-runner/project
15 changes: 10 additions & 5 deletions modules/coact.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ def datetime_converter(o: Any) -> Optional[str]:
return None


def parse_account(account: str, default_facility: str = "shared", default_repo: str = "default") -> tuple:
"""Split a slurm account of the form <facility>:<repo>[@<partition>][^<qos>] into (facility, repo)."""
facility, sep, repo = account.partition(":")
if not sep or not repo:
return default_facility, default_repo
return facility, re.split(r"[@^]", repo, maxsplit=1)[0]


def time_function(level="INFO"):
"""Decorator to time function execution and log the duration."""
def decorator(func):
Expand Down Expand Up @@ -770,11 +778,8 @@ def calc_resource_hours(startTs, endTs, tres: str, cluster: dict, alloc_nodes: O
return resource_time, elapsed_secs

d = {field: parts[idx] for field, idx in index.items()}
facility = default_facility
repo = default_repo
try:
facility, repo = d["Account"].split(":")
except Exception:
facility, repo = parse_account(d["Account"], default_facility, default_repo)
if (facility, repo) == (default_facility, default_repo) and ":" not in d["Account"]:
logger.warning(f"could not determine facility and repo from {d['Account']}")

startTs = parse_datetime(int(d["Start"]), force_tz=True)
Expand Down
Loading