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

[HTCondor-users] proper way to check fo undefined classAd in python

Hi experts !
I need to know what is the proper way to check if a classAd is Undefined
when using HTCondor python bindings.
Longish story short (check [1] if you care for context and details) :
I have some oldish python script which uses

import classad
.. get some classAd list via querying schedd via condor bindings...
  if someAd != classad.Value.Undefined:
    blah blah

and I found that it does not work anymore (new HTCondor release ?
I am running that with 9.2.0 atm) move to python3 ? It is a tiny corner
of our phase space and it went un-noticed for who knows how long).

Instead this works:
  if someAd is not classad.Value.

does nor work means that the output of someAd != classad.Value.Undefined
is not a boolean any more, with python debugger:
(Pdb) ad['CRAB_UserGroup'] != classad.Value.Undefined
undefined != undefined

Yes, I can replace "!=" with "is not", no problem, it works for me now,
but I need to know if this works by accident (like the previous way ? not
my code, do not shoot the messenger), or if it is the correct syntax
and will work forever. Or what is otherwise your recommendation.

I looked in https://htcondor.readthedocs.io/en/latest/apis/python-bindings/api/classad.html
but could not find this information (does not mean that it is not there, of course).