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

Re: [HTCondor-users] Python bindings: ExprTree vs classad.eval




> On Feb 5, 2021, at 9:35 AM, Thomas Hartmann <thomas.hartmann@xxxxxxx> wrote:
> 
> and another Python class ad question ;)
> 
> so, I have my class ad, that I can evaluate and let a variable point to the evulated result
> 
>   >>> pprint.pprint(  myjob.eval("RequestCpus")  )
>   1L
>   >>> FOO =  int(myjob.eval("RequestCpus"))
>   >>> pprint.pprint(FOO)
>   1
> 
> however, when I try to test on the evaluated(?) value, python throws an exception
> 
>    >>> if int( myjob.eval(["RequestCpus"])) not in cpus: ...
>   EXCEPTION [1]

Ah - small syntax error here.  I think you mean instead:

 if int( myjob.eval("RequestCpus")) not in cpus: 

When you add the square brackets [] you turn the input argument into a list.  That's what the exception is complaining about:

>    ClassAd.eval(ClassAd, list)
> did not match C++ signature:
>    eval(ClassAdWrapper {lvalue} self, std::string attr)

The input to eval() is a string, not a list.

> 
> testing on the assigned variable works, i.e.,
>    >>> if FOO not in cpus: ...
>    ððð
> 
> I actually tried to see, what happens when I use (deep)copy in the if clause on the ad-eval  - but got the same exception
> 
> What is Python here actually testing what in which order...? ð
> 
> I would have assumed, that functions would be called one by one and that the int(1L)~~> 1 then would be tested on `not in cpus`
> 
> Cheers,
>  Thomas
> 
> 
> [1]
> Traceback (most recent call last):
>  File "/tmp/jobsstats.py", line 166, in <module>
>    if int(myjob.eval(["RequestCpus"])) not in cpus:
> Boost.Python.ArgumentError: Python argument types in
>    ClassAd.eval(ClassAd, list)
> did not match C++ signature:
>    eval(ClassAdWrapper {lvalue} self, std::string attr)
> 
> _______________________________________________
> 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/