Skip to content

Commit

Permalink
Merge pull request cms-sw#40921 from lk11235/master
Browse files Browse the repository at this point in the history
HipPy update to python3
  • Loading branch information
cmsbuild authored Jan 8, 2024
2 parents c2bbc23 + a09ea59 commit 7924ce4
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Alignment/HIPAlignmentAlgorithm/python/common_cff_py.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ for sra in SelectorRigidAlignables:
if not tmpstrsrafound:
tmprigidalignables.append(sra)
else:
print "{} is already in the non-rigid alignables list. Omitting it in the rigid structures to align.".format(tmpstrsra)
print("{} is already in the non-rigid alignables list. Omitting it in the rigid structures to align.".format(tmpstrsra))
SelectorRigidAlignables = tmprigidalignables

process.AlignmentProducer.ParameterBuilder.SelectorBowed = cms.PSet(
Expand Down
25 changes: 19 additions & 6 deletions Alignment/HIPAlignmentAlgorithm/scripts/makeHippyCampaign.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,28 @@
import subprocess
import sys

basedir = "/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN2/HipPy"

thisfile = os.path.abspath(__file__)

def main():
parser = argparse.ArgumentParser()
parser.add_argument("foldername", help="folder name for the campaign. Example: CRUZET20xy")
parser.add_argument("--cmssw", default=os.environ["CMSSW_VERSION"])
parser.add_argument("--scram-arch", default=os.environ["SCRAM_ARCH"])
parser.add_argument("--subfolder", default="", help="subfolder within "+basedir+" to make 'foldername' in.")
parser.add_argument("--subfolder", default="", help="subfolder within basedir to make 'foldername' in.")
parser.add_argument("--merge-topic", action="append", help="things to cms-merge-topic within the CMSSW release created", default=[])
parser.add_argument("--print-sys-path", action="store_true", help=argparse.SUPPRESS) #internal, don't use this
parser.add_argument('--basedir', default="/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN2/HipPy")
args = parser.parse_args()

basedir = args.basedir
if not os.path.exists(basedir):
raise FileExistsError("Base Directory does not exist!")

if basedir[-1] == '/':
basedir = basedir[:-1] #No trailing slashed allowed

if args.print_sys_path:
print repr(sys.path)
print(repr(sys.path))
return

folder = os.path.join(basedir, args.subfolder, args.foldername)
Expand Down Expand Up @@ -100,7 +106,14 @@ def main():
shutil.copy(os.path.join(HIPAlignmentAlgorithm, "test", "hippysubmittertemplate.sh"), "submit_template.sh")
os.chmod("submit_template.sh", os.stat("submit_template.sh").st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
subprocess.check_call(["git", "add", "submit_template.sh"])


if not os.path.exists("submit_script.sh"):
shutil.copy(os.path.join(HIPAlignmentAlgorithm, "test", "hippysubmitterscript.sh"), "submit_script.sh")
os.chmod("submit_script.sh", os.stat("submit_script.sh").st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
subprocess.check_call(["git", "add", "submit_script.sh"])

print("Dumped files into ", folder)

try:
subprocess.check_output(["git", "diff", "--staged", "--quiet"])
except subprocess.CalledProcessError:
Expand Down Expand Up @@ -128,7 +141,7 @@ def cd(newdir):

def cmsenv():
output = subprocess.check_output(["scram", "ru", "-sh"])
for line in output.split(";\n"):
for line in output.decode('utf8').split(";\n"):
if not line.strip(): continue
match1 = re.match(r'^export (\w*)="([^"]*)"$', line)
match2 = re.match(r'^unset *((\w* *)*)$', line)
Expand Down
15 changes: 15 additions & 0 deletions Alignment/HIPAlignmentAlgorithm/test/hippysubmitterscript.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! /bin/bash

hipName="$(grep -m 1 "alignmentname=" $1 | cut -d= -f2)"

if [ -z "$hipName" ]
then
echo "Value for 'alignmentname' not found in template. Please check your submission template."
else
nohup ./$1 >> ../$hipName.log 2>&1 &
echo $hipName $! >> ../pid.nohup
echo "Please follow the log in '../$hipName.log'. To track progress live, use 'tail -f ../$hipName.log'."
echo "The nohup job PID is appended to '../pid.nohup' in case the submission should be killed."
echo "You can also use 'ps -ef | grep submit_' to find PIDs of currently running alignments."
fi

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -euo pipefail

voms-proxy-info | grep timeleft | grep -v -q 00:00:00 || (echo 'no proxy'; exit 1)

(echo $STY > /dev/null) || (echo "run this on a screen"; exit 1)
(echo $TMUX > /dev/null) || (echo "run this on a screen"; exit 1)

#hpnumber=
hptype=hp #or sm
Expand Down

0 comments on commit 7924ce4

Please sign in to comment.