Skip to content

Commit

Permalink
Added a maximum job time argument to ARC
Browse files Browse the repository at this point in the history
and passing it to the submit scripts
  • Loading branch information
alongd committed Mar 6, 2019
1 parent 4dcbeca commit 83eb5fa
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
21 changes: 18 additions & 3 deletions arc/job/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import csv
import logging

from arc.settings import arc_path, servers, submit_filename, delete_command,\
from arc.settings import arc_path, servers, submit_filename, delete_command, t_max_format,\
input_filename, output_filename, rotor_scan_resolution, list_available_nodes_command
from arc.job.submit import submit_scripts
from arc.job.inputs import input_files
Expand Down Expand Up @@ -66,6 +66,7 @@ class Job(object):
`occ` ``int`` The number of occupied orbitals (core + val) from a molpro CCSD sp calc
`initial_trsh` ``dict`` Troubleshooting methods to try by default. Keys are server names, values are trshs
`project_directory` ``str`` The path to the project directory
`max_job_time` ``int`` The maximal allowed job time on the server in hours
================ =================== ===============================================================================
self.job_status:
Expand All @@ -76,7 +77,8 @@ class Job(object):
def __init__(self, project, settings, species_name, xyz, job_type, level_of_theory, multiplicity, project_directory,
charge=0, conformer=-1, fine=False, shift='', software=None, is_ts=False, scan='', pivots=None,
memory=1500, comments='', trsh='', ess_trsh_methods=None, occ=None, initial_trsh=None, job_num=None,
job_server_name=None, job_name=None, job_id=None, server=None, date_time=None, run_time=None):
job_server_name=None, job_name=None, job_id=None, server=None, date_time=None, run_time=None,
max_job_time=5):
self.project = project
self.settings=settings
self.date_time = date_time if date_time is not None else datetime.datetime.now()
Expand All @@ -92,6 +94,7 @@ def __init__(self, project, settings, species_name, xyz, job_type, level_of_theo
self.ess_trsh_methods = ess_trsh_methods if ess_trsh_methods is not None else list()
self.trsh = trsh
self.initial_trsh = initial_trsh if initial_trsh is not None else dict()
self.max_job_time = max_job_time
job_types = ['conformer', 'opt', 'freq', 'optfreq', 'sp', 'composite', 'scan', 'gsm', 'irc', 'ts_guess']
# the 'conformer' job type is identical to 'opt', but we differentiate them to be identifiable in Scheduler
if job_type not in job_types:
Expand Down Expand Up @@ -315,7 +318,19 @@ def write_completed_job_to_csv_file(self):

def write_submit_script(self):
un = servers[self.server]['un'] # user name
self.submit = submit_scripts[self.software].format(name=self.job_server_name, un=un)
if self.max_job_time > 9999 or self.max_job_time == 0:
self.max_job_time = 9999
if t_max_format[servers[self.server]['cluster_soft']] == 'days':
# e.g., 5-0:00:00
d, h = divmod(self.max_job_time, 24)
t_max = '{0}-{0}:00:00'.format(d, h)
elif t_max_format[servers[self.server]['cluster_soft']] == 'hours':
# e.g., 120:00:00
t_max = '{0}:00:00'.format(self.max_job_time)
else:
raise JobError('Could not determine format for maximal job time')
self.submit = submit_scripts[servers[self.server]['cluster_soft']][self.software.lower()].format(
name=self.job_server_name, un=un, t_max=t_max)
if not os.path.exists(self.local_path):
os.makedirs(self.local_path)
with open(os.path.join(self.local_path, submit_filename[servers[self.server]['cluster_soft']]), 'wb') as f:
Expand Down
9 changes: 7 additions & 2 deletions arc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class ARC(object):
`t_min` ``tuple`` The minimum temperature for kinetics computations, e.g., (500, str('K'))
`t_max` ``tuple`` The maximum temperature for kinetics computations, e.g., (3000, str('K'))
`t_count` ``int`` The number of temperature points between t_min and t_max for kinetics computations
`max_job_time` ``int`` The maximal allowed job time on the server in hours
`rmgdb` ``RMGDatabase`` The RMG database object
====================== ========== ==================================================================================
Expand All @@ -82,7 +83,7 @@ def __init__(self, input_dict=None, project=None, arc_species_list=None, arc_rxn
conformer_level='', composite_method='', opt_level='', freq_level='', sp_level='', scan_level='',
ts_guess_level='', fine=True, generate_conformers=True, scan_rotors=True, use_bac=True,
model_chemistry='', ess_settings=None, initial_trsh=None, t_min=None, t_max=None, t_count=None,
verbose=logging.INFO, project_directory=None):
verbose=logging.INFO, project_directory=None, max_job_time=5):

self.__version__ = '1.0.0'
self.verbose = verbose
Expand All @@ -93,6 +94,7 @@ def __init__(self, input_dict=None, project=None, arc_species_list=None, arc_rxn
self.lib_long_desc = ''
self.unique_species_labels = list()
self.rmgdb = rmgdb.make_rmg_database_object()
self.max_job_time = max_job_time

if input_dict is None:
if project is None:
Expand Down Expand Up @@ -356,6 +358,7 @@ def as_dict(self):
restart_dict['t_min'] = self.t_min
restart_dict['t_max'] = self.t_max
restart_dict['t_count'] = self.t_count
restart_dict['max_job_time'] = self.max_job_time
return restart_dict

def from_dict(self, input_dict, project=None, project_directory=None):
Expand All @@ -377,6 +380,7 @@ def from_dict(self, input_dict, project=None, project_directory=None):
self.t0 = time.time() # init time
self.execution_time = None
self.verbose = input_dict['verbose'] if 'verbose' in input_dict else self.verbose
self.max_job_time = input_dict['max_job_time'] if 'max_job_time' in input_dict else 5

if self.ess_settings is not None:
self.settings['ssh'] = True
Expand Down Expand Up @@ -554,7 +558,8 @@ def execute(self):
scan_level=self.scan_level, ts_guess_level=self.ts_guess_level ,fine=self.fine,
settings=self.settings, generate_conformers=self.generate_conformers,
scan_rotors=self.scan_rotors, initial_trsh=self.initial_trsh, rmgdatabase=self.rmgdb,
restart_dict=self.restart_dict, project_directory=self.project_directory)
restart_dict=self.restart_dict, project_directory=self.project_directory,
max_job_time=self.max_job_time)

self.save_project_info_file()

Expand Down
6 changes: 4 additions & 2 deletions arc/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class Scheduler(object):
`save_restart` ``bool`` Whether to start saving a restart file. ``True`` only after all species are loaded
(otherwise saves a partial file and may cause loss of information)
`restart_path` ``str`` Path to the `restart.yml` file to be saved
`max_job_time` ``int`` The maximal allowed job time on the server in hours
`testing` ``bool`` Used for internal ARC testing (generating the object w/o executing it)
`rmgdb` ``RMGDatabase`` The RMG database object
======================= ========= ==================================================================================
Expand Down Expand Up @@ -104,13 +105,14 @@ class Scheduler(object):
"""
def __init__(self, project, settings, species_list, composite_method, conformer_level, opt_level, freq_level,
sp_level, scan_level, ts_guess_level, project_directory, rmgdatabase, fine=False, scan_rotors=True,
generate_conformers=True, initial_trsh=None, rxn_list=None, restart_dict=None,
generate_conformers=True, initial_trsh=None, rxn_list=None, restart_dict=None, max_job_time=5,
testing=False):
self.rmgdb = rmgdatabase
self.restart_dict = restart_dict
self.species_list = species_list
self.rxn_list = rxn_list if rxn_list is not None else list()
self.project = project
self.max_job_time = max_job_time
self.settings = settings
self.project_directory = project_directory
self.job_dict = dict()
Expand Down Expand Up @@ -468,7 +470,7 @@ def run_job(self, label, xyz, level_of_theory, job_type, fine=False, software=No
level_of_theory=level_of_theory, multiplicity=species.multiplicity, charge=species.charge, fine=fine,
shift=shift, software=software, is_ts=species.is_ts, memory=memory, trsh=trsh, conformer=conformer,
ess_trsh_methods=ess_trsh_methods, scan=scan, pivots=pivots, occ=occ, initial_trsh=self.initial_trsh,
project_directory=self.project_directory)
project_directory=self.project_directory, max_job_time=self.max_job_time)
if conformer < 0:
# this is NOT a conformer job
self.running_jobs[label].append(job.job_name) # mark as a running job
Expand Down

0 comments on commit 83eb5fa

Please sign in to comment.