Skip to content

Commit b49b190

Browse files
authored
Merge pull request #6850 from sfayer/add_priority
[v7r3] Add setPriority to Job API
2 parents 2ffb228 + 66f2b49 commit b49b190

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
@@ -804,6 +804,30 @@ def setJobGroup(self, jobGroup):
804804
self._addParameter(self.workflow, "JobGroup", "JDL", jobGroup, description)
805805
return S_OK()
806806

807+
#############################################################################
808+
def setPriority(self, priority):
809+
"""Helper function.
810+
811+
Sets the job priority in the range 1-10.
812+
Priorities 1-9 are matched probabilistically with higher numbers being more likely.
813+
Priority 10 jobs are always started before lower priority jobs from the same user.
814+
815+
Example usage:
816+
817+
>>> job = Job()
818+
>>> job.setPriority(5)
819+
820+
:param priority: Job priority
821+
:type priority: int
822+
"""
823+
if not isinstance(priority, int):
824+
return self._reportError("Expected int for priority", **{"priority": priority})
825+
826+
self.priority = priority
827+
description = "User Job Priority"
828+
self._addParameter(self.workflow, "Priority", "JDL", priority, description)
829+
return S_OK()
830+
807831
#############################################################################
808832
def setLogLevel(self, logLevel):
809833
"""Helper function.

0 commit comments

Comments
 (0)