Skip to content

Commit d4a7a59

Browse files
committed
Added python2 input parameter
1 parent cdf9e8e commit d4a7a59

File tree

4 files changed

+45
-17
lines changed

4 files changed

+45
-17
lines changed

pylhc/autosix.py

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,23 @@
204204
Mask to name jobs from replace_dict
205205
206206
207-
- **python** *(PathOrStr)*:
207+
- **python3** *(PathOrStr)*:
208208
209209
Path to python to use with sixdb (python3 with requirements
210210
installed).
211211
212212
default: ``python3``
213213
214214
215+
- **python2** *(PathOrStr)*:
216+
217+
Path to python to use with run_six.sh (python2 with requirements installed).
218+
ONLY THE PATH TO THE DIRECTORY OF THE python BINARY IS NEEDED!
219+
And it can't be an Anaconda Distribution.
220+
221+
default: None (uses the first `python` in path)
222+
223+
215224
- **resubmit**:
216225
217226
Resubmits if needed.
@@ -321,8 +330,16 @@ def get_params():
321330
help="Path to executable.",
322331
)
323332
params.add_parameter(
324-
name="python",
325-
default=DEFAULTS["python"],
333+
name="python2",
334+
default=DEFAULTS["python2"],
335+
type=PathOrStr,
336+
help=("Path to python to use with run_six.sh (python2 with requirements installed)."
337+
" ONLY THE PATH TO THE DIRECTORY OF THE python BINARY IS NEEDED!"
338+
" And it can't be an Anaconda Distribution."),
339+
)
340+
params.add_parameter(
341+
name="python3",
342+
default=DEFAULTS["python3"],
326343
type=PathOrStr,
327344
help="Path to python to use with sixdb (python3 with requirements installed).",
328345
)
@@ -388,7 +405,8 @@ def main(opt):
388405
basedir=opt.working_directory,
389406
# kwargs:
390407
ssh=opt.ssh,
391-
python=opt.python,
408+
python2=opt.python2,
409+
python3=opt.python3,
392410
unlock=opt.unlock,
393411
resubmit=opt.resubmit,
394412
da_turnstep=opt.da_turnstep,
@@ -426,7 +444,8 @@ def setup_and_run(jobname: str, basedir: Path, **kwargs):
426444
LOG.info(f"vv---------------- Job {jobname} -------------------vv")
427445
unlock: bool = kwargs.pop("unlock", False)
428446
ssh: str = kwargs.pop("ssh", None)
429-
python: Union[Path, str] = kwargs.pop("python", DEFAULTS["python"])
447+
python2: Union[Path, str] = kwargs.pop("python2", DEFAULTS["python2"])
448+
python3: Union[Path, str] = kwargs.pop("python3", DEFAULTS["python3"])
430449
resubmit: bool = kwargs.pop("resubmit", False)
431450
da_turnstep: int = kwargs.pop("da_turnstep", DEFAULTS["da_turnstep"])
432451
ignore_twissfail_check: bool = kwargs.pop("ignore_twissfail_check", False)
@@ -499,7 +518,7 @@ def setup_and_run(jobname: str, basedir: Path, **kwargs):
499518
> /afs/cern.ch/project/sixtrack/SixDesk_utilities/pro/utilities/bash/run_six.sh -a
500519
"""
501520
if check_ok:
502-
submit_sixtrack(jobname, basedir, ssh=ssh)
521+
submit_sixtrack(jobname, basedir, python=python2, ssh=ssh)
503522
return # takes even longer
504523

505524
with check_stage(STAGES.check_sixtrack_output, jobname, basedir) as check_ok:
@@ -515,7 +534,7 @@ def setup_and_run(jobname: str, basedir: Path, **kwargs):
515534
> /afs/cern.ch/project/sixtrack/SixDesk_utilities/pro/utilities/bash/run_six.sh -i
516535
"""
517536
if check_ok:
518-
check_sixtrack_output(jobname, basedir, ssh=ssh, resubmit=resubmit)
537+
check_sixtrack_output(jobname, basedir, python=python2, ssh=ssh, resubmit=resubmit)
519538

520539
with check_stage(STAGES.sixdb_load, jobname, basedir) as check_ok:
521540
"""
@@ -524,7 +543,7 @@ def setup_and_run(jobname: str, basedir: Path, **kwargs):
524543
> python3 /afs/cern.ch/project/sixtrack/SixDesk_utilities/pro/utilities/externals/SixDeskDB/sixdb . load_dir
525544
"""
526545
if check_ok:
527-
sixdb_load(jobname, basedir, python=python, ssh=ssh)
546+
sixdb_load(jobname, basedir, python=python3, ssh=ssh)
528547

529548
with check_stage(STAGES.sixdb_cmd, jobname, basedir) as check_ok:
530549
"""
@@ -537,7 +556,7 @@ def setup_and_run(jobname: str, basedir: Path, **kwargs):
537556
> python3 /afs/cern.ch/project/sixtrack/SixDesk_utilities/pro/utilities/externals/SixDeskDB/sixdb $jobname plot_da_vs_turns
538557
"""
539558
if check_ok:
540-
sixdb_cmd(jobname, basedir, cmd=["da"], python=python, ssh=ssh)
559+
sixdb_cmd(jobname, basedir, cmd=["da"], python=python3, ssh=ssh)
541560

542561
# da_vs_turns is broken at the moment (jdilly, 19.10.2020)
543562
# sixdb_cmd(jobname, basedir, cmd=['da_vs_turns', '-turnstep', str(da_turnstep), '-outfile'],

pylhc/constants/autosix.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
HEADER_BASEDIR = "BASEDIR"
2929

3030
DEFAULTS = dict(
31-
python="python3",
31+
python2=None,
32+
python3="python3",
3233
da_turnstep=100,
3334
executable=MADX_BIN,
3435
)

pylhc/data_extract/timber.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def find_exact_time_for_beamprocess(acc_time: AccDatetime) -> AccDatetime:
1818
KnobExtractor, the timing event for SQUEEZE or RAMP.
1919
I don't think this is correct (jdilly).
2020
"""
21-
db = pytimber.LoggingDB()
21+
db = pytimber.LoggingDB(source="nxcals")
2222
t1, t2 = acc_time.sub(days=1).local_string(), acc_time.local_string()
2323

2424
event_ts, event_val = db.get("HX:SRMP-POW", t1, t2)["HX:SRMP-POW"]

pylhc/sixdesk_tools/submit.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,17 @@ def check_sixtrack_input(jobname: str, basedir: Path, ssh: str = None, resubmit:
4949
LOG.info("Check for input files was successful.")
5050

5151

52-
def submit_sixtrack(jobname: str, basedir: Path, ssh: str = None, resubmit: bool = False):
52+
def submit_sixtrack(jobname: str, basedir: Path, python: Path = None, ssh: str = None, resubmit: bool = False):
5353
""" Generate simulation files and check if runnable and submit. """
5454
re_str = "Re-" if resubmit else ""
5555
LOG.info(f"{re_str}Submitting to sixtrack.")
5656
sixjobs_path = get_sixjobs_path(jobname, basedir)
57+
args = ["-i"] if resubmit else ["-a"]
58+
if python is not None:
59+
if not python.is_dir():
60+
python = python.parent
61+
args += ["-P", str(python)]
5762
try:
58-
args = ["-i"] if resubmit else ["-a"]
5963
start_subprocess([RUNSIX_SH] + args, cwd=sixjobs_path, ssh=ssh) # throws OSError if failed
6064
except OSError as e:
6165
raise StageSkip(
@@ -66,20 +70,24 @@ def submit_sixtrack(jobname: str, basedir: Path, ssh: str = None, resubmit: bool
6670
LOG.info(f"{re_str}Submitted jobs to Sixtrack")
6771

6872

69-
def check_sixtrack_output(jobname: str, basedir: Path, ssh: str = None, resubmit: bool = False):
73+
def check_sixtrack_output(jobname: str, basedir: Path, python: Union[Path, str], ssh: str = None, resubmit: bool = False):
7074
""" Checks if the sixtrack output is all there. """
7175
LOG.info("Checking if sixtrack has finished.")
7276
sixjobs_path = get_sixjobs_path(jobname, basedir)
7377
try:
7478
start_subprocess([RUNSTATUS_SH], cwd=sixjobs_path, ssh=ssh)
7579
except OSError as e:
7680
if resubmit:
77-
submit_sixtrack(jobname, basedir, ssh, resubmit=True)
78-
raise StageSkip("Resubmitted incomplete sixtrack jobs.")
81+
submit_sixtrack(jobname, basedir, python=python, ssh=ssh, resubmit=True)
82+
raise StageSkip(
83+
f"Sixtrack for {jobname} seems to be incomplete."
84+
" Resubmitted incomplete sixtrack jobs."
85+
" Wait until they have finished and run again."
86+
)
7987
else:
8088
raise StageSkip(
8189
f"Sixtrack for {jobname} seems to be incomplete."
82-
f"Run possibly not finished. Check (debug-) log or your Scheduler."
90+
f" Run possibly not finished. Check (debug-) log or your Scheduler."
8391
) from e
8492
else:
8593
LOG.info("Sixtrack results are all present.")

0 commit comments

Comments
 (0)