Skip to content

Commit

Permalink
Add options while setting up Rocoto XML that are useful for CI (#1365)
Browse files Browse the repository at this point in the history
Adds options for maximum tries (default is 2), cyclethrottle (default is 3), taskthrottle (default is 25) and verbosity (default is 10)
  • Loading branch information
aerorahul committed Mar 2, 2023
1 parent 6024e68 commit 5d6c71a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
2 changes: 2 additions & 0 deletions docs/source/setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ Example:

./setup_xml.py /some_safe_disk_area/Joe.Schmo/expdir/test

Additional options for setting up Rocoto are available with `setup_xml.py -h` that allow users to change the number of failed tries, number of concurrent cycles and tasks as well as Rocoto's verbosity levels.

****************************************
Step 4: Confirm files from setup scripts
****************************************
Expand Down
12 changes: 7 additions & 5 deletions workflow/rocoto/workflow_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@
from datetime import datetime
from pygw.timetools import to_timedelta
from collections import OrderedDict
from typing import Dict
from applications import AppConfig
from rocoto.workflow_tasks import get_wf_tasks
import rocoto.rocoto as rocoto


class RocotoXML:

def __init__(self, app_config: AppConfig) -> None:
def __init__(self, app_config: AppConfig, rocoto_config: Dict) -> None:

self._app_config = app_config
self.rocoto_config = rocoto_config

self._base = self._app_config.configs['base']

Expand Down Expand Up @@ -60,7 +62,7 @@ def _get_definitions(self) -> str:
entity['ROTDIR'] = self._base['ROTDIR']
entity['JOBS_DIR'] = self._base['BASE_JOB']

entity['MAXTRIES'] = self._base.get('ROCOTO_MAXTRIES', 2)
entity['MAXTRIES'] = self.rocoto_config['maxtries']

# Put them all in an XML key-value syntax
strings = []
Expand All @@ -75,9 +77,9 @@ def _get_workflow_header(self):
"""

scheduler = self._app_config.scheduler
cyclethrottle = self._base.get('ROCOTO_CYCLETHROTTLE', 3)
taskthrottle = self._base.get('ROCOTO_TASKTHROTTLE', 25)
verbosity = self._base.get('ROCOTO_VERBOSITY', 10)
cyclethrottle = self.rocoto_config['cyclethrottle']
taskthrottle = self.rocoto_config['taskthrottle']
verbosity = self.rocoto_config['verbosity']

expdir = self._base['EXPDIR']

Expand Down
15 changes: 14 additions & 1 deletion workflow/setup_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ def input_args():
parser.add_argument('expdir', help='full path to experiment directory containing config files',
type=str, default=os.environ['PWD'])

parser.add_argument('--maxtries', help='maximum number of retries', type=int,
default=2, required=False)
parser.add_argument('--cyclethrottle', help='maximum number of concurrent cycles', type=int,
default=3, required=False)
parser.add_argument('--taskthrottle', help='maximum number of concurrent tasks', type=int,
default=25, required=False)
parser.add_argument('--verbosity', help='verbosity level of Rocoto', type=int,
default=10, required=False)

args = parser.parse_args()

return args
Expand All @@ -45,6 +54,10 @@ def check_expdir(cmd_expdir, cfg_expdir):
if __name__ == '__main__':

user_inputs = input_args()
rocoto_param_dict = {'maxtries': user_inputs.maxtries,
'cyclethrottle': user_inputs.cyclethrottle,
'taskthrottle': user_inputs.taskthrottle,
'verbosity': user_inputs.verbosity}

cfg = Configuration(user_inputs.expdir)

Expand All @@ -54,5 +67,5 @@ def check_expdir(cmd_expdir, cfg_expdir):
app_config = AppConfig(cfg)

# Create Rocoto Tasks and Assemble them into an XML
xml = RocotoXML(app_config)
xml = RocotoXML(app_config, rocoto_param_dict)
xml.write()

0 comments on commit 5d6c71a

Please sign in to comment.