Skip to content

Commit

Permalink
Fix spread and co-loc due to vice versa role assignment. Remove f_com…
Browse files Browse the repository at this point in the history
…pact (makes no sense)
  • Loading branch information
nikosT committed Aug 9, 2024
1 parent 556e7f4 commit 3cac113
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 35 deletions.
2 changes: 1 addition & 1 deletion etc/oar/admission_rules.d/15_check_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
r8 = "^allowed=\\w+$"
r9 = "^inner=\\w+$"
r10 = "^timesharing=(?:(?:\\*|user),(?:\\*|name)|(?:\\*|name),(?:\\*|user))$"
r11 = "^(?:compact|f_compact|spread|f_spread|co_loc|f_co_loc|no_pref|exclusive)$"
r11 = "^(?:compact|spread|f_spread|co_loc|f_co_loc|no_pref|exclusive)$"
all_re = re.compile(
"(%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s)"
% (r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11)
Expand Down
39 changes: 6 additions & 33 deletions oar/kao/custom_scheduling.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def compact(itvs_slots, hy_res_rqts, hy, beginning_slotset, reverse=True):
return result


def spread(itvs_slots, hy_res_rqts, hy, beginning_slotset, reverse=False):
def spread(itvs_slots, hy_res_rqts, hy, beginning_slotset, reverse=True):
"""
Given a job resource request and a set of resources this function tries to find a matching allocation.
Expand Down Expand Up @@ -165,7 +165,7 @@ def co_loc(itvs_slots, hy_res_rqts, hy, beginning_slotset):
:return [ProcSet]: \
The allocation if found, otherwise an empty :class:`procset.ProcSet`
"""
return spread(itvs_slots, hy_res_rqts, hy, beginning_slotset, reverse=True)
return spread(itvs_slots, hy_res_rqts, hy, beginning_slotset, reverse=False)


def no_pref(itvs_slots, hy_res_rqts, hy, beginning_slotset):
Expand All @@ -186,34 +186,7 @@ def no_pref(itvs_slots, hy_res_rqts, hy, beginning_slotset):
return compact(itvs_slots, hy_res_rqts, hy, beginning_slotset, reverse=False)


def f_compact(itvs_slots, hy_res_rqts, hy, beginning_slotset, reverse=True):
"""
Given a job resource request and a set of resources this function tries to find a matching allocation.
.. note::
This` can be override with the oar `extension <../admin/extensions.html#functions-assign-and-find>`_ mechanism.
:param session: The DB session
:param itvs_slots: A procset of the resources available for the allocation
:type itvs_slots: :class:`procset.ProcSet`
:param hy_res_rqts: The job's request
:param hy: The definition of the resources hierarchy
:return [ProcSet]: \
The allocation if found, otherwise an empty :class:`procset.ProcSet`
"""
avail_procset = compact(
itvs_slots, hy_res_rqts, hy, beginning_slotset, reverse=reverse
)

# if no allocation space is found (by compact policy)
# fallback to spread policy
if len(avail_procset) == 0:
return spread(itvs_slots, hy_res_rqts, hy, beginning_slotset)
else:
return avail_procset


def f_spread(itvs_slots, hy_res_rqts, hy, beginning_slotset, reverse=False):
def f_spread(itvs_slots, hy_res_rqts, hy, beginning_slotset, reverse=True):
"""
Given a job resource request and a set of resources this function tries to find a matching allocation.
Expand All @@ -233,9 +206,9 @@ def f_spread(itvs_slots, hy_res_rqts, hy, beginning_slotset, reverse=False):
)

# if no allocation space is found (by compact policy)
# fallback to spread
# fallback to compact/no_pref
if len(avail_procset) == 0:
return compact(itvs_slots, hy_res_rqts, hy, beginning_slotset)
return compact(itvs_slots, hy_res_rqts, hy, beginning_slotset, reverse=reverse)
else:
return avail_procset

Expand All @@ -255,4 +228,4 @@ def f_co_loc(itvs_slots, hy_res_rqts, hy, beginning_slotset):
:return [ProcSet]: \
The allocation if found, otherwise an empty :class:`procset.ProcSet`
"""
return f_spread(itvs_slots, hy_res_rqts, hy, beginning_slotset, reverse=True)
return f_spread(itvs_slots, hy_res_rqts, hy, beginning_slotset, reverse=False)
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ build-backend = "poetry.masonry.api"
compact = "oar.kao.custom_scheduling:compact"
spread = "oar.kao.custom_scheduling:spread"
co_loc = "oar.kao.custom_scheduling:co_loc"
f_compact = "oar.kao.custom_scheduling:f_compact"
f_spread = "oar.kao.custom_scheduling:f_spread"
f_co_loc = "oar.kao.custom_scheduling:f_co_loc"
no_pref = "oar.kao.custom_scheduling:no_pref"

0 comments on commit 3cac113

Please sign in to comment.