ATLAS Offline Software
Loading...
Searching...
No Matches
ELG_jediState.py
Go to the documentation of this file.
1# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
2
3
4def ELG_jediState(sample) :
5 """ Returns state of the jobs.
6
7 State returned as an int based on an enum in the PrunDriver.cxx :
8 `enum Enum { DONE=0, PENDING=1, FAIL=2 };`
9 Make sure these values are kept the same in both files.
10 Extra values are added to capture extra states, those start at 90.
11
12 """
13 from enum import IntEnum
14 class Status(IntEnum):
15 DONE = 0
16 PENDING = 1
17 FAIL = 2
18 RUNNING = 90
19 OTHER = 91
20 SCRIPT_FAIL = 99
21
22
23 try:
24 from pandatools import PandaToolsPkgInfo # noqa: F401
25 except ImportError:
26 print ("prun needs additional setup, try:")
27 print (" lsetup panda")
28 return Status.SCRIPT_FAIL
29
30 jediTaskID = int(sample.meta().castDouble("nc_jediTaskID", 0))
31
32 if jediTaskID < 100 :
33 print ("Sample " + sample.name() + " does not have a jediTaskID")
34 return Status.SCRIPT_FAIL
35
36 from pandatools import Client
37
38 taskDict = {}
39 taskDict['jediTaskID'] = jediTaskID
40 detail = Client.getJediTaskDetails(taskDict, False, True)
41 if detail[0] != 0 :
42 print ("Problem checking status of task %s with id %s" % (sample.name(), jediTaskID))
43 return Status.SCRIPT_FAIL
44
45 status = detail[1]['status']
46
47 if status == "done": return Status.DONE
48 elif status == "failed": return Status.FAIL
49 # Finished returning FAIL status is original
50 # behavior from the PrunDriver.cxx
51 elif status == "finished": return Status.FAIL
52 elif status == "running": return Status.RUNNING
53
54 # Value for states not considered by PrunDriver.cxx
55 return Status.OTHER