-
Notifications
You must be signed in to change notification settings - Fork 39
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
New Site.acceleratorParams as json-like dictionary #7470
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice, thanks for introducing use to the use of contextlib ! Sort of "even too careful", I am not sure that we need to validate all acceleratorparams here, but surely looks good.
I have a couple general comments:
Should we propose to add the new validate_dict method to WMCore so it stays together with other validate_* ?
I am curious if you considered to generalize this to accept an additionalParams argument to the REST which is a dictionary like `additionaParams={k1:v1, k2,v2, ...} Where REST only validates the structure as a dictionary and stores it in the DB. Then applications like TaskWorker retrieve it and look e.g. for k=acceleratorParams, or k=someOtherThings and then expand the value as needed and in case raise an exception there if format is not good. While I respect the idea of the REST/Server.py original developer to protect the REST against attacks, I am not sure that in our use case we gain. In a way making it possible to pass one more paramerter from Client to Server w/o changing the REST code has its advantages.
Ok. I will open PR.
No. REST.validate() does input validate/sanitize that it is safe to use anywhere in our service. Let's say you have a new On the contrary, you want to deprecate What we do to validate user input in REST is just copy/paste pattern, nothing new. |
@belforte One question before opening PR to WMCore. |
I think we disagree on whether it is more convenient to validate About PR for WMCore and flattening dictionary in client, the whole point here was to be able add some other params to accparams w/o changing code in Client and REST, and possibly pass them in the JDL as a classad w/o any manipulation. If that's not possible, I would question the usefulness of all this, review very critically the design and look for a different way. There is also the secondary advantage of not needing to introduce new columns in the DB. Anyhow I still think it nice to be able use a dictionary as REST arg, which your |
For the client, YES, I agree with you. But for the REST, NO. You still need to validate value inside dict, and
Or may I ask how do you plan to validate in TW? |
Yes, your approach is the "correct" one and in line with the original REST design. I am simply sloppy and lazy and imagine that a wrong key name or value would result in an exception down the road which will hopefully be clear in its message. Yeah.. I know, that basically mean no validation: take a json object from client and use it. I agree that it is not a safe practice. I am happy to take your code as is, as I already wrote. Anyhow AFAIC see the plan is:
|
9102d0b
to
815966c
Compare
Thanks Stefano. |
Jenkins results:
|
Part of #6989
Client side: dmwm/CRABClient#5179
New
Site.acceleratorParams
configuration option to let users request specific GPU by specify GPU parameter as json-like key/value dictionary.It is optional argument but require
Site.requireAccelerator
to beTrue
.Support
CUDACapabilities
,CUDARuntime
, andGPUMemoryMB
keys.Note that server get json string from client and parse in new
validate_dict
contextmanager and expose tuple ofRESTArgs
back to with statement and execute key validation statement inside.