[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [HTCondor-users] Change submit parameter configuration knob with python bindings



Hi Kenyi,

It looks like htcondor.param is expecting you to pass in purely string expressions, and only does conversion on the way back out to you. In particular, this works:

In [1]: import htcondor                                                                                              Â

In [2]: htcondor.param.get("SUBMIT_GENERATE_CUSTOM_RESOURCE_REQUIREMENTS") Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
Out[2]: True

In [10]: htcondor.param["SUBMIT_GENERATE_CUSTOM_RESOURCE_REQUIREMENTS"] = "false" Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â

In [11]: htcondor.param.get("SUBMIT_GENERATE_CUSTOM_RESOURCE_REQUIREMENTS") Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
Out[11]: False

In [12]: type(htcondor.param.get("SUBMIT_GENERATE_CUSTOM_RESOURCE_REQUIREMENTS")) Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
Out[12]: bool


I've noted this on a related ticket on our end (Âhttps://htcondor-wiki.cs.wisc.edu/index.cgi/tktview?tn=7658,4Â).

Note that since the key is already set, you probably don't want to use setdefault, since


In [2]: htcondor.param.setdefault("SUBMIT_GENERATE_CUSTOM_RESOURCE_REQUIREMENTS", "false") Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
Out[2]: 'true'

(setdefault only sets if the key is not set, seeÂhttps://docs.python.org/3/library/stdtypes.html#dict.setdefault)


Josh Karpel


On Fri, Jun 26, 2020 at 2:51 PM Kenyi Hurtado Anampa <khurtado@xxxxxx> wrote:
Hi,

I would like to change the following parameter that defaults to True:

SUBMIT_GENERATE_CUSTOM_RESOURCE_REQUIREMENTS = False

via python bindings, using HTCondor 8.9.7. htcondor.param should allow
for that, but it seems it only supports string values. Is this
correct? Is there any other way for setting this parameter?

>>> import htcondor
>>> htcondor.param.get("SUBMIT_GENERATE_CUSTOM_RESOURCE_REQUIREMENTS")
True
>>>
type(htcondor.param.get("SUBMIT_GENERATE_CUSTOM_RESOURCE_REQUIREMENTS"))
<type 'bool'>
>>>
htcondor.param.setdefault("SUBMIT_GENERATE_CUSTOM_RESOURCE_REQUIREMENTS", False)
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "/usr/lib64/python2.7/site-packages/htcondor/_lock.py", line
75, in wrapper
  rv = func(*args, **kwargs)
Boost.Python.ArgumentError: Python argument types in
  _Param.setdefault(_Param, str, bool)
did not match C++ signature:
  setdefault(Param {lvalue}, std::string, std::string)
>>> htcondor.param["SUBMIT_GENERATE_CUSTOM_RESOURCE_REQUIREMENTS"] = False
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "/usr/lib64/python2.7/site-packages/htcondor/_lock.py", line
75, in wrapper
  rv = func(*args, **kwargs)
Boost.Python.ArgumentError: Python argument types in
  _Param.__setitem__(_Param, str, bool)
did not match C++ signature:
  __setitem__(Param {lvalue}, std::string, std::string)

Best regards,
Kenyi
_______________________________________________
HTCondor-users mailing list
To unsubscribe, send a message to htcondor-users-request@xxxxxxxxxxx with a
subject: Unsubscribe
You can also unsubscribe by visiting
https://lists.cs.wisc.edu/mailman/listinfo/htcondor-users

The archives can be found at:
https://lists.cs.wisc.edu/archive/htcondor-users/