Skip to content

Commit

Permalink
Improves logging system by flushing.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSchuy committed Mar 30, 2018
1 parent c0a6a5c commit 8b39065
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ def gen(batch_size, num_batches, evnt_dir, release, job_config, run_number):
evnt_files.append(evnt_file)
first_event = num_batches * (i - 1) + 1
seed = int(time.time()) % max_seed
log_file_handle = open(os.path.join(constants.log_dir, 'gen{}.log'.format(i)), 'w+')
log_file = os.path.join(constants.log_dir, 'gen{}.log'.format(i))
log_file_handle = open(log_file, 'w+')
st = os.stat(log_file)
os.chmod(log_file, st.st_mode | stat.S_IWOTH)
tmp_dir = tempfile.mkdtemp(dir=constants.tmp_dir)
tmp_dirs.append(tmp_dir)
arg = '. /phys/users/gwatts/bin/CommonScripts/configASetup.sh && . $AtlasSetup/scripts/asetup.sh here,{} && Generate_tf.py --jobConfig {} --maxEvents {} --runNumber {} --firstEvent {} --outputEVNTFile {} --ecmEnergy 13000 --randomSeed {}'.format(release, job_config, batch_size, run_number, first_event, evnt_file, seed)
Expand Down
5 changes: 4 additions & 1 deletion reco.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import shutil
import subprocess32
import string
import sys

def reco(evnt_file, version, output_dir, num_events, skip_events, log_file, tmp_dir):
log_file_handle = open(log_file, 'w+')
Expand All @@ -14,15 +15,17 @@ def reco(evnt_file, version, output_dir, num_events, skip_events, log_file, tmp_
command = tag.command.format(input_file, output_file) + ' --maxEvents {} --skipEvents {}'.format(num_events, skip_events)
arg = '{} {} && {}'.format(asetup, tag.release, command)
print('{} arg: {}'.format(tag.tag, arg))
sys.stdout.flush()
try:
subprocess32.check_call(arg, executable='/bin/bash', cwd=tmp_dir, shell=True, stdout=log_file_handle, stderr=subprocess32.STDOUT)
except subprocess32.CalledProcessError as e:
print('reco.py: {}'.format(e))
sys.stdout.flush()
break
input_file = output_file
# move the aod file to the output directory, and make it immutable so that
# it is not accidentally deleted.
os.rename(os.path.join(output_dir, output_file), os.path.join(output_dir, output_file))
os.rename(os.path.join(tmp_dir, output_file), os.path.join(output_dir, output_file))
output_file_path = os.path.join(output_dir, output_file)
st = os.stat(output_file_path)
not_writable = ~(stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH)
Expand Down

0 comments on commit 8b39065

Please sign in to comment.