104 """Perform the transcription of a script with submit prefix commands
105 to a DAG format, which can then be submitted on HTCondor."""
108 args =
parse(sys.argv)
109 script = Path(args.script)
110 batchname = script.name
113 outputDir = Path(args.dag)
114 outputDir_preexists = outputDir.exists()
115 rescue_preexists = len(list(outputDir.glob(
"dag.rescue*"))) > 0
116 if outputDir_preexists:
117 print(
"(Re)submitting existing dag.")
122 if outputDir_preexists
and not rescue_preexists:
123 cmd = f
"condor_submit -batch-name {batchname}"
125 cmd = f
"condor_submit_dag -import_env -batch-name {batchname}"
132 if outputDir_preexists
and not rescue_preexists:
133 cmd += f
" dag.condor.sub"
138 path = os.environ[
"PATH"]
139 ld_library_path = os.environ[
"LD_LIBRARY_PATH"]
140 env = os.environ.copy()
141 env[
"PATH"] = f
"{outputDir}:{path}"
142 env[
"LD_LIBRARY_PATH"] = f
"{outputDir}:{ld_library_path}"
145 if which(
"condor_submit_dag")
is None or which(
"condor_submit")
is None:
146 print(
"HTCondor shell commands cannot be found.")
147 sys.exit(
not args.dry_run)
148 subprocess.run(cmd, shell=
True, env=env, check=
True, cwd=outputDir)
153 cmd =
"condor_q -dag -nobatch"
155 print(f
"Check the status of your jobs with `{cmd}`.")
159 def handler(signum, frame):
161 f
"condor_rm -constraint 'JobBatchName == \"{batchname}\"'", shell=
True
165 signal.signal(signal.SIGINT, handler)
168 cmd = f
"watch -t -d {cmd}"
169 subprocess.run(cmd, check=
True, shell=
True)