-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modified setup_dirac_proxy
time parsing to allow for proxies with time greater than 24 hours
#46
Modified setup_dirac_proxy
time parsing to allow for proxies with time greater than 24 hours
#46
Conversation
Thanks for finding and figuring out this bug. I thought that running Context for any other potential reviewers: Among other things, if timeleft_str == "00:00:00" I just wanted to make sure that The optimal way would be to remove all the string parsing and write our own python2 script that interacts with gbasf2/dirac and has a return value depending on whether the proxy is still and run that as a subprocess. If there isn't already a script for that we aren't aware of. But that shouldn't be our worry in this PR, on a first glance this looks really good and I will look at the code of the whole function again after having slept out. |
The I agree that a python2 script interfacing directly with gbasf2/dirac is the ultimate solution to this. This snippet of code retrieves the time left (in seconds) if a proxy is active. I haven't tested its behaviour if a proxy is not active. Judging by how from BelleDIRAC.gbasf2.lib.auth import getProxyInfo
ProxyInfo = getProxyInfo()
seconds = ProxyInfo["Value"]["secondsLeft"] EDIT: I just checked the behaviour of |
Cool that you found how to do it. We can use that it exits with an exit code of if seconds == 0:
sys.exit(1) and put that script into
Then, we can call that in a subprocess and if the return code is 0 (successful I'm surprised that the option |
I just created a new branch and implemented this idea. For the code you can look here: I also have a commit in there which improves how this method is called during execution, namely as a side effect of |
I just tested this, and found the maximum length I could initialise a proxy for was 136 days, which is the same amount of time my VOMS AUP signature is valid for. So I figure that is the upper limit. (The command will succeed if you pass a much larger number, but will set the time to the maximum value.)
Yes. Tested the snippet in isolation, and also as a part of job submission. I read the code on your new branch, and it all looks good to me. Two questions/comments:
|
So far I had only written a python2 script like this for obtaining a json with all the job statuses, since this is the core part of my wrapper and there I had had bugs before that. Why I haven't replaced everything yet was laziness and I don't like working with gbasf2 code, since I can't just pip-install it on my notebook and then all the nice IDE features I have hear like "jump to definition" etc. don't work, so finding things in the BelleDirac code is harder for me. I opened a new issue for that with all instances where I think I could replace this with similar code here: #47 Also, I opened an issue for your suggestions regarding the proxy time: #48 |
Thanks to both of you for the PR and the discussion. |
This PR can be merged. Michael is working on a more comprehensive change on another branch, but this fix is good for now. |
I initialised a proxy for 72 hours, but the time parsing failed, since
setup_dirac_proxy
tried to match a string like'71:42:32'
to'%H:%M:%S'
.As far as I know, there is no
strptime
alternative to%H
to accept numbers greater than 23. In this PR, I split the time string and pass each component totimedelta
, which resolves the issue.