From 8c40c717293a967d9da6d5ffe68185a4540f19c4 Mon Sep 17 00:00:00 2001 From: tmaeno Date: Wed, 30 Oct 2024 16:06:06 +0100 Subject: [PATCH] added option name check in pbook.retry --- ChangeLog.txt | 3 +++ pandaclient/PBookScript.py | 18 ++++++++++++++++++ pandaclient/PandaToolsPkgInfo.py | 2 +- pandaclient/PrunScript.py | 14 +++++++++++++- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 0c47f8f..1a071ba 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,5 +1,8 @@ ** Release Notes +1.5.79 + * added option name check in pbook.retry + 1.5.78 * protection against missing THistSvc diff --git a/pandaclient/PBookScript.py b/pandaclient/PBookScript.py index b38a0b2..f52dacf 100644 --- a/pandaclient/PBookScript.py +++ b/pandaclient/PBookScript.py @@ -69,6 +69,9 @@ def list_parallel_exec(func, array): # fork PID fork_child_pid = None +# options of client tools +client_options = None + # exit action def _onExit(dirName, hFile): @@ -256,6 +259,21 @@ def retry(taskIDs, newOpts=None, days=14, limit=1000, **kwargs): """ if newOpts is None: newOpts = kwargs + global client_options + if newOpts: + # get valid option list + if client_options is None: + from pandaclient import PrunScript + + client_options = PrunScript.main(get_options=True) + # check options + for key in list(newOpts): + if key == "memory": + newOpts["ramCount"] = newOpts[key] + del newOpts[key] + elif key not in client_options: + print('Error: Unknown option name "%s"' % key) + return None if isinstance(taskIDs, (list, tuple)): ret = list_parallel_exec(lambda taskID: pbookCore.retry(taskID, newOpts=newOpts), taskIDs) elif isinstance(taskIDs, (int, long)): diff --git a/pandaclient/PandaToolsPkgInfo.py b/pandaclient/PandaToolsPkgInfo.py index 5bcb977..68be1fd 100644 --- a/pandaclient/PandaToolsPkgInfo.py +++ b/pandaclient/PandaToolsPkgInfo.py @@ -1 +1 @@ -release_version = "1.5.78" +release_version = "1.5.79" diff --git a/pandaclient/PrunScript.py b/pandaclient/PrunScript.py index bf47234..5ce9a56 100644 --- a/pandaclient/PrunScript.py +++ b/pandaclient/PrunScript.py @@ -30,7 +30,15 @@ # main -def main(get_taskparams=False, ext_args=None, dry_mode=False): +def main(get_taskparams=False, ext_args=None, dry_mode=False, get_options=False): + """ + Execute prun command + :param get_taskparams: get task parameters and return them if True + :param ext_args: external arguments to be passed to prun + :param dry_mode: execute prun in dry mode + :param get_options: get options and return them if True + :return: task parameters or options if get_taskparams or get_options is True + """ # default cloud/site defaultCloud = None defaultSite = "AUTO" @@ -1249,6 +1257,10 @@ def main(get_taskparams=False, ext_args=None, dry_mode=False): print(options) print("") + # return options + if get_options: + return vars(options) + # display version from pandaclient import PandaToolsPkgInfo