Migrating From Version 1
When switching from version 1 of the HTCondor Python bindings to version 2, it should mostly just work to do the following:
import classad as classad
import htcondor2 as htcondor
The goal of this guide is to help when it doesn’t. In general, code that you haven’t (but need to) migrate will simply raise an exception of some kind.
Warning
There is an incompability between classad
and classad2
that
won’t manifest itself as an exception. You should check your code
for calls to eval()
and simplify()
that don’t specify a
positional parameter (the scope): classad2.ExprTree
no
longer records which classad2.ClassAd
, if any, it was extracted
from. Calls to eval()
or simplify()
without an argument may
therefore return different values (likely None
).
This change was required for proper memory management.
You should otherwise be able to search this document for the method or class mentioned in the exception.
The classad2
Module
Building New ExprTree
s
The big difference between the version 1 classad
API and the
classad2
API is that the version 2 module does not allow
construction or modification of ExprTree
objects. For example,
the following is no longer supported:
>>> import classad
>>> seven = classad.ExprTree("7")
>>> eight = classad.ExprTree("8")
>>> fifteen = seven + eight
>>> print(fifteen)
7 + 8
>>> print(fifteen.eval())
15
You could instead write the following:
>>> import classad2
>>> seven = classad2.ExprTree("7")
>>> eight = classad2.ExprTree("8")
>>> fifteen = classad2.ExprTree(f"{seven} + {eight}")
>>> print(fifteen)
7 + 8
>>> print(fifteen.eval())
15
Classes or methods only in Version 1:
classad.register()
This method was dropped; as far as we know, no one was using it.
Classes or methods only in Version 1:
The htcondor
Module
Job Submission
Note
Oops, we changed it again.
The widest-ranging change to the htcondor2
API is the elimination of
all of the previously-deprecated submission-related functionality, and the
correction and expansion of the remaining method,
htcondor2.Schedd.submit()
. The new submit
method only takes
htcondor.Submit
objects; you may no longer submit via raw
ClassAds. However, the Submit
object now supports all submit
files, and the submit()
method respects any queue
statements
in the Submit
object unless you specify otherwise.
Submitting jobs now looks something like this:
import htcondor2
submit = htcondor2.Submit("""
executable = my_prog
arguments = data_file $(SCENARIO) --seed $(SEED)
transfer_input_files = data_file $(SCENARIO)
transfer_output_files = $(SCENARIO).result
request_cpus = 1
request_memory = 4096
out = $(SCENARIO).out
err = $(SCENARIO).err
log = my_prog.log
queue 1 SCENARIO matching file scenarios/*
""")
submit["SEED"] = "0xDEADBEEF"
schedd = htcondor2.Schedd()
result = schedd.submit(submit)
Note that the submit-language variable SEED
was specified as a
a string. The HTCondor submit language (which is not the ClassAd
language) only understands strings, so in version 2, the Submit
object no longer attempts to translate them for you.
Classes or methods only in Version 1:
Unimplemented Methods
These methods are not presently implemented in the version 2 bindings, but we will consider implementing them upon request. We generally hope that they are no longer necessary.
Classes or methods only in Version 1:
Unimplemented Classes
htcondor.SecMan
is not presently implemented. Because
htcondor.Token
was only used by SecMan
, it has also
been removed.
htcondor.TokenRequest
is not presently implemented.
Classes or methods only in Version 1:
Deprecated Classes or Methods Now Removed
We removed the deprecated method htcondor.Schedd.xquery()
; use
htcondor2.Schedd.query()
instead. This removed the need for its
dedicated return type, htcondor.QueryIterator
, and for the
htcondor.poll()
method and its return type,
htcondor.BulkQueryIterator
, and for the latter’s dedicated
enumeration, htcondor.BlockingMode
.
Classes or methods only in Version 1:
Other Missing Classes or Methods
htcondor.HistoryIterator
has been replaced as the return type
of htcondor2.Schedd.history()
with List[ClassAd]
.
htcondor.QueueItemsIterator
has been replaced as the return type
of htcondor2.Submit.itemdata()
with Iterator[List[str]]
.
htcondor.VacateTypes
has been removed, as it was never used
in a documented interface.
htcondor.CredStatus
was never fully documented and has been removed,
as it was was never used in a documented interface.
Classes or methods only in Version 1: