Skip to content

Commit a41f2d4

Browse files
sfayerweb-flow
authored andcommitted
sweep: #6850 Add setPriority to Job API
1 parent 51ef0b7 commit a41f2d4

File tree

1 file changed

+24
-0
lines changed
  • src/DIRAC/Interfaces/API

1 file changed

+24
-0
lines changed

src/DIRAC/Interfaces/API/Job.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,30 @@ def setJobGroup(self, jobGroup):
777777
self._addParameter(self.workflow, "JobGroup", "JDL", jobGroup, description)
778778
return S_OK()
779779

780+
#############################################################################
781+
def setPriority(self, priority):
782+
"""Helper function.
783+
784+
Sets the job priority in the range 1-10.
785+
Priorities 1-9 are matched probabilistically with higher numbers being more likely.
786+
Priority 10 jobs are always started before lower priority jobs from the same user.
787+
788+
Example usage:
789+
790+
>>> job = Job()
791+
>>> job.setPriority(5)
792+
793+
:param priority: Job priority
794+
:type priority: int
795+
"""
796+
if not isinstance(priority, int):
797+
return self._reportError("Expected int for priority", **{"priority": priority})
798+
799+
self.priority = priority
800+
description = "User Job Priority"
801+
self._addParameter(self.workflow, "Priority", "JDL", priority, description)
802+
return S_OK()
803+
780804
#############################################################################
781805
def setLogLevel(self, logLevel):
782806
"""Helper function.

0 commit comments

Comments
 (0)