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