-
Notifications
You must be signed in to change notification settings - Fork 8
Support for sending hadd jobs to condor #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
abbywarden
wants to merge
4
commits into
DisplacedVertices:master
Choose a base branch
from
abbywarden:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9795972
support to submit hadd jobs to condor
abbywarden 71a5a7b
better output print statements for condor mhadd and simplified hadd_c…
abbywarden 91cad65
more complete print statements for mhadd
abbywarden c728510
more robust hadding on condor to work on all machines; main author : Ang
abbywarden File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| #!/usr/bin/env python | ||
|
|
||
| import sys | ||
| import os | ||
| import subprocess | ||
| import stat | ||
| from JMTucker.Tools.CMSSWTools import cmssw_base | ||
|
|
||
| def make_bash_file(cmssw_tar_path, bash_file_path): | ||
| cmssw_name = cmssw_base().rsplit("/")[-1] | ||
| bash_meat = '''#!/bin/bash | ||
| workdir=$(pwd) | ||
| echo "Starting job on " `date` #Date/time of start of job | ||
| echo "Running on: `uname -a`" #Condor job is running on this node | ||
| echo "System software: `cat /etc/redhat-release`" #Operating System on that node | ||
| export SCRAM_ARCH=__SCRAM_ARCH__ | ||
| source /cvmfs/cms.cern.ch/cmsset_default.sh | ||
| scram project CMSSW __CMSSW_VERSION__ 2>&1 > /dev/null | ||
| scramexit=$? | ||
| if [[ $scramexit -ne 0 ]]; then | ||
| echo scram exited with code $scramexit | ||
| exit $scramexit | ||
| fi | ||
| cd __CMSSW_VERSION__ | ||
| tar xf ${workdir}/input.tgz | ||
| cd src | ||
| eval `scram ru -sh` | ||
| scram b -j 2 2>&1 > /dev/null | ||
|
|
||
| #python JMTucker/Tools/python/hadd.py $1 ${@:2} | ||
| cd ${workdir} | ||
| hadd.py $1 ${@:2} | ||
| ''' \ | ||
| .replace('__SCRAM_ARCH__', os.environ['SCRAM_ARCH']) \ | ||
| .replace('__CMSSW_VERSION__', os.environ['CMSSW_VERSION']) | ||
|
|
||
| bash_file = open(bash_file_path+'/bash_condor.sh', 'w') | ||
| bash_file.write(bash_meat) | ||
| bash_file.close() | ||
| subprocess.check_call(['chmod', '+x', bash_file_path+'/bash_condor.sh']) | ||
| return | ||
|
|
||
|
|
||
| def hadd_on_condor(new_name, job_dir, cmssw_tar_path, input_files): | ||
| output_file_path = os.path.dirname(os.path.abspath(new_name)) | ||
| new_nice_name = (new_name.rsplit("/")[-1]).replace('.root','') | ||
| job_dir = os.path.abspath(job_dir) | ||
| cmssw_tar_path = os.path.abspath(cmssw_tar_path) | ||
| is_eos = '/store/' in new_name | ||
| if not is_eos: | ||
| new_name = new_nice_name+'.root' | ||
|
|
||
| hadd_job_dir = job_dir+'/mhadd/' | ||
| if not os.path.exists(hadd_job_dir): | ||
| os.mkdir(hadd_job_dir) | ||
|
|
||
| make_bash_file(cmssw_tar_path, hadd_job_dir) | ||
|
|
||
| #requirements necessary for wisconsin machines -- comment out if not needed | ||
| # the CentOS == 7 requires proxy with 2048 bit and will fail with usual 1024 | ||
| # voms-proxy-init -rfc -valid 144:00 -voms cms -bits 2048 | ||
| condorFile = open(hadd_job_dir+'/submit_'+new_nice_name, 'w') | ||
| condorFile.write('universe = vanilla\n') | ||
| condorFile.write('executable = '+hadd_job_dir+'/bash_condor.sh\n') | ||
| condorFile.write('arguments = '+new_name+' ' + ' '.join(input_files) + '\n') | ||
| condorFile.write('log = '+hadd_job_dir+'/hadd.log\n') | ||
| condorFile.write('output = '+hadd_job_dir+'/hadd.out\n') | ||
| condorFile.write('error = '+hadd_job_dir+'/hadd.err\n') | ||
| condorFile.write('requirements = TARGET.HAS_OSG_WN_CLIENT =?= TRUE\n') | ||
| condorFile.write('requirements = TARGET.OpSysMajorVer == 7\n') | ||
| condorFile.write('should_transfer_files = yes\n') | ||
| condorFile.write('when_to_transfer_output = ON_EXIT\n') | ||
| condorFile.write('transfer_input_files = '+cmssw_tar_path+'\n') | ||
|
|
||
| if not is_eos: | ||
| condorFile.write('Transfer_Output_Files = '+new_nice_name+'.root, '+new_nice_name+'.root.haddlog'+'\n') | ||
|
|
||
| condorFile.write('queue\n') | ||
| condorFile.close() | ||
|
|
||
| submit_path = os.getcwd() | ||
| if not is_eos: | ||
| submit_path = output_file_path | ||
| args = ['condor_submit '+hadd_job_dir+'/submit_'+new_nice_name] | ||
| p = subprocess.Popen(args =args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True, cwd=submit_path) | ||
|
|
||
| print p.stdout.read() | ||
|
|
||
| return p | ||
|
|
||
| _all__ = [ | ||
| 'make_bash_file', | ||
| 'hadd_on_condor', | ||
| ] | ||
|
|
||
| if __name__ == '__main__': | ||
|
|
||
| hadd_on_condor(sys.argv[1], sys.argv[2], sys.argv[3:]) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which ones are to be commented out, is it these?
TARGET.HAS_OSG_WN_CLIENT =?= TRUETARGET.OpSysMajorVer == 7Rather than commenting in/out, you could do something like https://github.com/DisplacedVertices/cmssw-usercode/blob/master/Tools/python/ROOTTools.py#L1576-L1595 with the HOSTNAME