|
DAS
3.0
Das Analysis System
|
|
def | preparse (List[str] argv, str tutorial, bool multi_opt=False, bool dag_opt=False, bool condor=False) |
|
None | git_hash (str exec) |
|
def | find_institute () |
|
None | tweak_helper_multi (PrefixCommand prefix, bool multi_opt=True, bool dag_opt=False, bool condor=False) |
|
None | diagnostic (Exception exception) |
|
def | print_slice (formatting, line, nNow, nSplit, end) |
|
def | copy_condor_config (output) |
|
◆ copy_condor_config()
def copy_condor_config |
( |
|
output | ) |
|
Copy the HTC config to the running directory.
397 """Copy the HTC config to the running directory."""
399 copy2(Path(__file__).parent /
"condor.jdl", str(output) +
"/.condor")
◆ diagnostic()
None diagnostic |
( |
Exception |
exception | ) |
|
Common diagnostic message for all prefix commands in case of exception.
357 """Common diagnostic message for all prefix commands in case of exception."""
358 prefix = os.path.basename(sys.argv[0])
360 check_output(
"printDarwinSoftwareVersion", shell=
True)
365 versions += [f
"Python {sys.version_info.major}.{sys.version_info.minor}"]
367 f
"\x1B[31m{prefix}: \x1B[1m{exception}\x1B[22m",
369 "Consider opening a GitLab issue if you don't understand the cause of the failure.\x1B[0m",
◆ find_institute()
Identifies the host from the name of the machine
117 """Identifies the host from the name of the machine"""
120 r"naf-cms[1-2][0-9].desy.de":
"DESY",
121 r".phy.pku.edu.cn":
"PKU",
122 r"lxplus[0-9]*.cern.ch":
"CERN",
125 hostname = socket.gethostname()
126 for key, value
in clusters.items():
127 if re.search(key, hostname):
130 raise RuntimeError(
"The host could not be identified")
◆ git_hash()
None git_hash |
( |
str |
exec | ) |
|
Returns the SHA of the executable at compile time.
112 """Returns the SHA of the executable at compile time."""
113 print(check_output(exec +
" -g", shell=
True).decode(), end=
"")
◆ preparse()
def preparse |
( |
List[str] |
argv, |
|
|
str |
tutorial, |
|
|
bool |
multi_opt = False , |
|
|
bool |
dag_opt = False , |
|
|
bool |
condor = False |
|
) |
| |
Parser for the prefix command itself, relying on ArgumentParser.
35 multi_opt: bool =
False,
36 dag_opt: bool =
False,
39 """Parser for the prefix command itself, relying on ArgumentParser."""
41 parser = ArgumentParser(add_help=
False)
43 parser.add_argument(
"exec", nargs=
"?")
45 parser.add_argument(
"-b",
"--background", action=
"store_true")
46 parser.add_argument(
"-d",
"--dry-run", action=
"store_true")
48 parser.add_argument(
"-D",
"--dag", type=Path, nargs=
'?', default=
"dag")
50 parser.add_argument(
"-n",
"--memory-needs", type=int, default=1024)
53 parser.add_argument(
"-h",
"--help", action=
"store_true")
54 parser.add_argument(
"-t",
"--tutorial", action=
"store_true")
55 parser.add_argument(
"-g",
"--git", action=
"store_true")
57 parser.add_argument(
"-e",
"--example", action=
"store_true")
60 parser.add_argument(
"-v",
"--verbose", action=
"store_true")
61 parser.add_argument(
"-m",
"--mute", action=
"store_true")
62 parser.add_argument(
"-f",
"--fill", action=
"store_true")
63 parser.add_argument(
"-F",
"--Friend", action=
"store_true")
64 parser.add_argument(
"-s",
"--syst", action=
"store_true")
65 parser.add_argument(
"-c",
"--config", type=Path)
66 parser.add_argument(
"-j",
"--nSplit", type=int, default=NPROC)
69 cmds, args = parser.parse_known_intermixed_args(argv[1:])
71 if any(x
in args
for x
in [
"-k",
"--nNow"]):
72 raise ValueError(
"Giving `-k` or `--nNow` is meaningless in this context.")
73 unknown_explicit_args = [arg
for arg
in args
if arg[0] ==
"-"]
74 if len(unknown_explicit_args) > 0:
76 f
"No unknown explicit option is allowed: {unknown_explicit_args}"
91 args += [
"-c", str(cmds.config.resolve())]
94 if cmds.help
or len(argv) == 1:
95 prefix = os.path.basename(sys.argv[0])
97 f
"\33[1m{prefix} exec args [...]\33[0m",
98 "where\texec = a command using `Darwin::Tools::Options` with `Darwin::Tools::split`",
99 "\targs = the arguments of the same command, one being called exactly `output`",
104 lines = textwrap.TextWrapper(width=80).wrap(text=tutorial)
105 print(*lines, sep=
"\n")
◆ print_slice()
def print_slice |
( |
|
formatting, |
|
|
|
line, |
|
|
|
nNow, |
|
|
|
nSplit, |
|
|
|
end |
|
) |
| |
Prefix the output stream with the slice. The formatting of the
printout is preserved but the slice is printed in default formatting.
374 def print_slice(formatting, line, nNow, nSplit, end):
376 Prefix the output stream with the slice. The formatting of the
377 printout is preserved but the slice is printed in default formatting.
383 special_chars = re.findall(
r"\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])", line)
386 if special_chars
and special_chars[-1] == RESET:
389 formatting +=
"".join(special_chars)
391 print(f
"{nNow}/{nSplit}\t{formatting}{line}{RESET}", end=end)
◆ tweak_helper_multi()
None tweak_helper_multi |
( |
PrefixCommand |
prefix, |
|
|
bool |
multi_opt = True , |
|
|
bool |
dag_opt = False , |
|
|
bool |
condor = False |
|
) |
| |
Tweak helper to use a directory as output rather than a file
and to reflect the number of cores of the machine.
326 prefix: PrefixCommand,
327 multi_opt: bool =
True,
328 dag_opt: bool =
False,
329 condor: bool =
False,
331 """Tweak helper to use a directory as output rather than a file
332 and to reflect the number of cores of the machine."""
334 print(f
"\33[1m{prefix.name} \33[0m", end=
"")
335 for row
in prefix.helper:
337 row = row.replace(
"ROOT file",
"directory")
342 "(=1)" if NPROC < 10
else "(=1) ",
"(=" + str(NPROC) +
")"
347 print(
" -b [ --background ] Do not wait for job to finish")
348 print(
" -d [ --dry-run ] Run until the actual executation")
350 print(
" -D [ --dag ] Indicate DAG file")
352 print(
" -n [ --memory-needs] arg Memory needs for HTCondor job")
◆ __all__
◆ NPROC
NPROC = multiprocessing.cpu_count() |
None diagnostic(Exception exception)
Definition: prefix.py:356
def copy_condor_config(output)
Definition: prefix.py:396
def find_institute()
Definition: prefix.py:116
def preparse(List[str] argv, str tutorial, bool multi_opt=False, bool dag_opt=False, bool condor=False)
Definition: prefix.py:32
def print_slice(formatting, line, nNow, nSplit, end)
Definition: prefix.py:374
None git_hash(str exec)
Definition: prefix.py:111
None tweak_helper_multi(PrefixCommand prefix, bool multi_opt=True, bool dag_opt=False, bool condor=False)
Definition: prefix.py:325