DAS  3.0
Das Analysis System
try Namespace Reference

Functions

None tweak_helper (List[str] helper)
 
def main ()
 

Variables

int MAX_N_EVENTS = 100
 

Function Documentation

◆ main()

def try.main ( )
Implementation of `try` command, relying on homemade `prefix` lib.
26 def main():
27  """Implementation of `try` command, relying on homemade `prefix` lib."""
28 
29  cmds, args = prefix.preparse(
30  sys.argv,
31  tutorial=(
32  f"Runs the command for {MAX_N_EVENTS} events. Only commands "
33  "running over n-tuples may be prefixed, and must natively "
34  "output a ROOT file."
35  ),
36  )
37 
38  pref_try = prefix.PrefixCommand(sys.argv[0], cmds)
39 
40  if cmds.help:
41  tweak_helper(pref_try.helper)
42 
43  if cmds.git:
44  prefix.git_hash(cmds.exec)
45 
46  if cmds.help or cmds.git:
47  sys.exit()
48 
49  pref_try.parse(args)
50  pref_try.prepare_io(multi = False)
51 
52  output = str(pref_try.absoutput)
53 
54  if os.path.isdir(pref_try.output):
55  pref_try.output += f"/0{pref_try.extension}"
56 
57  shell_cmd = (
58  [pref_try.cmds.exec]
59  + pref_try.inputs
60  + [output]
61  + pref_try.args
62  )
63 
64  if pref_try.splittable and len(pref_try.inputs) > 0:
65  nevents = pref_try.get_entries(pref_try.inputs[0])
66  # \todo This will only work for parallelisable commands taking a TTree as input -> we should find a way to change that (will also need to change the helper message).
67  pref_try.nSplit = max(nevents // MAX_N_EVENTS, 1)
68  shell_cmd += ["-j", str(pref_try.nSplit)]
69 
70  print(" ".join(shell_cmd))
71  subprocess.run(shell_cmd, check=True)
72 
73 

◆ tweak_helper()

None try.tweak_helper ( List[str]  helper)
Tweak the helper from the C++ executables and exits.
13 def tweak_helper(helper: List[str]) -> None:
14  """Tweak the helper from the C++ executables and exits."""
15 
16  print("\33[1mtry \33[0m", end="")
17  for row in helper:
18  if "nNow" in row:
19  continue
20  if "nSplit" in row:
21  continue
22  print(row)
23  print("")
24 
25 

Variable Documentation

◆ MAX_N_EVENTS

int MAX_N_EVENTS = 100
prefix.PrefixCommand
Definition: prefix.py:133
prefix.preparse
def preparse(List[str] argv, str tutorial, bool multi_opt=False, bool dag_opt=False, bool condor=False)
Definition: prefix.py:32
try.tweak_helper
None tweak_helper(List[str] helper)
Definition: try.py:13
try.main
def main()
Definition: try.py:26
prefix.git_hash
None git_hash(str exec)
Definition: prefix.py:111