Skip to content

Fix SlurmFlag Enum and ReservationReoccurrence Enum #374

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

Merged
merged 3 commits into from
Feb 2, 2025
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
14 changes: 7 additions & 7 deletions pyslurm/core/reservation.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ from datetime import datetime
from pyslurm import xcollections
from pyslurm.utils.helpers import instance_to_dict
from pyslurm.utils.enums import SlurmEnum, SlurmFlag
from enum import auto, StrEnum
from enum import auto
from pyslurm.utils.ctime import (
_raw_time,
timestr_to_mins,
Expand Down Expand Up @@ -541,9 +541,9 @@ class ReservationReoccurrence(SlurmEnum):

See {scontrol#OPT_Flags} for more info.
"""
NO = auto()
DAILY = auto(), slurm.RESERVE_FLAG_DAILY, slurm.RESERVE_FLAG_NO_DAILY
HOURLY = auto(), slurm.RESERVE_FLAG_HOURLY, slurm.RESERVE_FLAG_NO_HOURLY
WEEKLY = auto(), slurm.RESERVE_FLAG_WEEKLY, slurm.RESERVE_FLAG_NO_WEEKLY
WEEKDAY = auto(), slurm.RESERVE_FLAG_WEEKDAY, slurm.RESERVE_FLAG_NO_WEEKDAY
WEEKEND = auto(), slurm.RESERVE_FLAG_WEEKEND, slurm.RESERVE_FLAG_NO_WEEKEND
NO = "NO"
DAILY = "DAILY", slurm.RESERVE_FLAG_DAILY, slurm.RESERVE_FLAG_NO_DAILY
HOURLY = "HOURLY", slurm.RESERVE_FLAG_HOURLY, slurm.RESERVE_FLAG_NO_HOURLY
WEEKLY = "WEEKLY", slurm.RESERVE_FLAG_WEEKLY, slurm.RESERVE_FLAG_NO_WEEKLY
WEEKDAY = "WEEKDAY", slurm.RESERVE_FLAG_WEEKDAY, slurm.RESERVE_FLAG_NO_WEEKDAY
WEEKEND = "WEEKEND", slurm.RESERVE_FLAG_WEEKEND, slurm.RESERVE_FLAG_NO_WEEKEND
10 changes: 9 additions & 1 deletion pyslurm/utils/enums.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,15 @@ class SlurmEnum(str, Enum, metaclass=DocstringSupport):
class SlurmFlag(Flag, metaclass=DocstringSupport):

def __new__(cls, flag, *args):
obj = super()._new_member_(cls)
parent = super()
if hasattr(parent, "_new_member_"):
# For Python >= 3.10, use _new_member_.
# We could very likely just also use object.__new__, but it works
# here, so no need to change it now.
obj = parent._new_member_(cls)
else:
obj = object.__new__(cls)

obj._value_ = int(flag)
obj._clear_flag = int(args[0]) if len(args) >= 1 else 0
return obj
Expand Down
Loading