Skip to content

Commit

Permalink
nCPUS -> n_threads
Browse files Browse the repository at this point in the history
  • Loading branch information
kjvbrt committed Jan 9, 2025
1 parent 126cc74 commit 1203c53
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def __init__(self, cmdline_args):
# there once the batch job is done, default is empty
# self.output_dir_eos = '/eos/experiment/fcc/ee/analyses/case-studies/' \
# f'higgs/mH-recoil/stage1_{self.ana_args.muon_pt}'
self.output_dir_eos = '/eos/user/j/jsmiesko/FCCAnalyses/output'

# Optional: type for eos, needed when <outputDirEos> is specified. The
# default is FCC EOS, which is eospublic
Expand Down
2 changes: 1 addition & 1 deletion man/man7/fccanalysis-script.7
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ Default value: empty string
\fBnCPUS\fR (optional)
Number of threads the RDataFrame will use\&.
.br
Default value: 4
Default value: 1
.TP
\fBrunBatch\fR (optional)
Run the analysis on the HTCondor batch system.
Expand Down
24 changes: 14 additions & 10 deletions python/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def determine_os(local_dir: str) -> str | None:


# _____________________________________________________________________________
def create_condor_config(log_dir: str,
def create_condor_config(config: dict[str, Any],
log_dir: str,
process_name: str,
build_os: str | None,
rdf_module,
Expand Down Expand Up @@ -81,7 +82,7 @@ def create_condor_config(log_dir: str,

cfg += '+AccountingGroup = "%s"\n' % get_element(rdf_module, 'comp_group')

cfg += 'RequestCpus = %i\n' % get_element(rdf_module, "n_threads")
cfg += f'RequestCpus = {config["n-threads"]}\n'

cfg += 'should_transfer_files = yes\n'
cfg += 'when_to_transfer_output = on_exit\n'
Expand Down Expand Up @@ -111,7 +112,8 @@ def create_condor_config(log_dir: str,


# _____________________________________________________________________________
def create_subjob_script(local_dir: str,
def create_subjob_script(config: dict[str, Any],
local_dir: str,
analysis,
process_name: str,
chunk_num: int,
Expand All @@ -135,10 +137,10 @@ def create_subjob_script(local_dir: str,

scr += 'which fccanalysis\n'
# scr += local_dir
scr += f'fccanalysis run {anapath} --batch'
scr += f'fccanalysis run {anapath}'
scr += f' --output {output_path}'
if hasattr(analysis, 'n_threads'):
scr += ' --ncpus ' + str(get_element(analysis, "n_threads"))
scr += f' --n-threads {config["n-threads"]}'
if len(cmd_args.remaining) > 0:
scr += ' ' + ' '.join(cmd_args.unknown)
scr += ' --files-list'
Expand Down Expand Up @@ -260,7 +262,8 @@ def send_to_batch(config: dict[str, Any],
for i in range(3):
try:
with open(subjob_script_path, 'w', encoding='utf-8') as ofile:
subjob_script = create_subjob_script(local_dir,
subjob_script = create_subjob_script(config,
local_dir,
analysis,
sample_name,
ch_num,
Expand Down Expand Up @@ -288,7 +291,8 @@ def send_to_batch(config: dict[str, Any],
for i in range(3):
try:
with open(condor_config_path, 'w', encoding='utf-8') as cfgfile:
condor_config = create_condor_config(log_dir,
condor_config = create_condor_config(config,
log_dir,
sample_name,
determine_os(local_dir),
analysis,
Expand All @@ -305,6 +309,6 @@ def send_to_batch(config: dict[str, Any],

batch_cmd = f'condor_submit -spool {condor_config_path}'
LOGGER.info('Batch command:\n %s', batch_cmd)
success = submit_job(batch_cmd, 10)
if not success:
sys.exit(3)
# success = submit_job(batch_cmd, 10)
# if not success:
# sys.exit(3)
2 changes: 1 addition & 1 deletion python/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def setup_run_parser(parser):
help='run over the test input file')
parser.add_argument('--bench', action='store_true', default=False,
help='output benchmark results to a JSON file')
parser.add_argument('-j', '--ncpus', type=int, default=-1,
parser.add_argument('-j', '--ncpus', '--n-threads', type=int,
help='set number of threads')
parser.add_argument('-g', '--graph', action='store_true', default=False,
help='generate computational graph of the analysis')
Expand Down
5 changes: 5 additions & 0 deletions python/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ def merge_config_analysis_class(config: dict[str, Any],
else:
config['input-directory'] = None

if hasattr(analysis_class, 'n_threads'):
config['n-threads'] = analysis_class.n_threads
else:
config['n-threads'] = 1

return config


Expand Down

0 comments on commit 1203c53

Please sign in to comment.