Skip to content

Commit

Permalink
Merge pull request #36 from tmaeno/master
Browse files Browse the repository at this point in the history
added option name check in pbook.retry
  • Loading branch information
tmaeno authored Oct 30, 2024
2 parents a8031a7 + 8c40c71 commit 24d4379
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
3 changes: 3 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
** Release Notes

1.5.79
* added option name check in pbook.retry

1.5.78
* protection against missing THistSvc

Expand Down
18 changes: 18 additions & 0 deletions pandaclient/PBookScript.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)):
Expand Down
2 changes: 1 addition & 1 deletion pandaclient/PandaToolsPkgInfo.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
release_version = "1.5.78"
release_version = "1.5.79"
14 changes: 13 additions & 1 deletion pandaclient/PrunScript.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 24d4379

Please sign in to comment.