htcondor API Reference

This page is an exhaustive reference of the API exposed by the htcondor module. It is not meant to be a tutorial for new users but rather a helpful guide for those who already understand the basic usage of the module.

Interacting with Collectors

class htcondor.Collector(pool)

Client object for a remote condor_collector. The interaction with the collector broadly has three aspects:

  • Locating a daemon.
  • Query the collector for one or more specific ClassAds.
  • Advertise a new ad to the condor_collector.
Parameters:pool (str or list[str]) – A host:port pair specified for the remote collector (or a list of pairs for HA setups). If omitted, the value of configuration parameter COLLECTOR_HOST is used.
locate(daemon_type, name) → object :

Query the condor_collector for a particular daemon.

Parameters:
  • daemon_type (DaemonTypes) – The type of daemon to locate.
  • name (str) – The name of daemon to locate. If not specified, it searches for the local daemon.
Returns:

a minimal ClassAd of the requested daemon, sufficient only to contact the daemon; typically, this limits to the MyAddress attribute.

Return type:

ClassAd

locateAll(daemon_type) → object :

Query the condor_collector daemon for all ClassAds of a particular type. Returns a list of matching ClassAds.

Parameters:daemon_type (DaemonTypes) – The type of daemon to locate.
Returns:Matching ClassAds
Return type:list[ClassAd]
query(ad_type=htcondor._htcondor.AdTypes.Any, constraint='', projection=[], statistics='') → object :

Query the contents of a condor_collector daemon. Returns a list of ClassAds that match the constraint parameter.

Parameters:
  • ad_type (AdTypes) – The type of ClassAd to return. If not specified, the type will be ANY_AD.
  • constraint (str or ExprTree) – A constraint for the collector query; only ads matching this constraint are returned. If not specified, all matching ads of the given type are returned.
  • attrs (list[str]) – A list of attributes to use for the projection. Only these attributes, plus a few server-managed, are returned in each ClassAd.
  • statistics (list[str]) – Statistics attributes to include, if they exist for the specified daemon.
Returns:

A list of matching ads.

Return type:

list[ClassAd]

directQuery(daemon_type, name='', projection=[], statistics='') → object :

Query the specified daemon directly for a ClassAd, instead of using the ClassAd from the condor_collector daemon. Requires the client library to first locate the daemon in the collector, then querying the remote daemon.

Parameters:
  • daemon_type (DaemonTypes) – Specifies the type of the remote daemon to query.
  • name (str) – Specifies the daemon’s name. If not specified, the local daemon is used.
  • projection (list[str]) – is a list of attributes requested, to obtain only a subset of the attributes from the daemon’s ClassAd.
  • statistics (str) – Statistics attributes to include, if they exist for the specified daemon.
Returns:

The ad of the specified daemon.

Return type:

ClassAd

advertise(ad_list, command='UPDATE_AD_GENERIC', use_tcp=True) → None :

Advertise a list of ClassAds into the condor_collector.

Parameters:
  • ad_list (list[ClassAds]) – ClassAds to advertise.
  • command (str) – An advertise command for the remote condor_collector. It defaults to UPDATE_AD_GENERIC. Other commands, such as UPDATE_STARTD_AD, may require different authorization levels with the remote daemon.
  • use_tcp (bool) – When set to True, updates are sent via TCP. Defaults to True.
class htcondor.DaemonTypes

An enumeration of different types of daemons available to HTCondor.

The values of the enumeration are:

None
Any

Any type of daemon; useful when specifying queries where all matching daemons should be returned.

Master

Ads representing the condor_master.

Schedd

Ads representing the condor_schedd.

Startd

Ads representing the resources on a worker node.

Collector

Ads representing the condor_collector.

Negotiator

Ads representing the condor_negotiator.

HAD

Ads representing the high-availability daemons (condor_had).

Generic

All other ads that are not categorized as above.

Credd
class htcondor.AdTypes

A list of different types of ads that may be kept in the condor_collector.

The values of the enumeration are:

None
Any

Type representing any matching ad. Useful for queries that match everything in the collector.

Generic

Generic ads, associated with no particular daemon.

Startd

Startd ads, produced by the condor_startd daemon. Represents the available slots managed by the startd.

StartdPrivate

The “private” ads, containing the claim IDs associated with a particular slot. These require additional authorization to read as the claim ID may be used to run jobs on the slot.

Schedd

Schedd ads, produced by the condor_schedd daemon.

Master

Master ads, produced by the condor_master daemon.

Collector

Ads from the condor_collector daemon.

Negotiator

Negotiator ads, produced by the condor_negotiator daemon.

Submitter

Ads describing the submitters with available jobs to run; produced by the condor_schedd and read by the condor_negotiator to determine which users need a new negotiation cycle.

Grid

Ads associated with the grid universe.

HAD

Ads produced by the condor_had.

License

License ads. These do not appear to be used by any modern HTCondor daemon.

Credd
Defrag
Accounting

Interacting with Schedulers

class htcondor.Schedd(location_ad)

Client object for a condor_schedd.

Parameters:location_ad (ClassAd) – An Ad describing the location of the remote condor_schedd daemon, as returned by the Collector.locate() method. If the parameter is omitted, the local condor_schedd daemon is used.
transaction(flags=0, continue_txn=False) → Transaction :

Start a transaction with the condor_schedd.

Starting a new transaction while one is ongoing is an error unless the continue_txn flag is set.

Parameters:
  • flags (TransactionFlags) – Flags controlling the behavior of the transaction, defaulting to 0.
  • continue_txn (bool) – Set to True if you would like this transaction to extend any pre-existing transaction; defaults to False. If this is not set, starting a transaction inside a pre-existing transaction will cause an exception to be thrown.
Returns:

A transaction context manager object.

query(constraint='true', attr_list=[], callback=None, limit=-1, opts=htcondor._htcondor.QueryOpts.Default) → object :

Query the condor_schedd daemon for jobs.

Warning

This returns a list of ClassAd objects, meaning all results must be buffered in memory. This may be memory-intensive for large responses; we strongly recommend to utilize the xquery()

Parameters:
  • constraint (str or ExprTree) – Query constraint; only jobs matching this constraint will be returned; defaults to 'true'.
  • attr_list (list[str]) – Attributes for the condor_schedd daemon to project along. At least the attributes in this list will be returned. The default behavior is to return all attributes.
  • callback – A callable object; if provided, it will be invoked for each ClassAd. The return value (if not None) will be added to the returned list instead of the ad.
  • limit (int) – The maximum number of ads to return; the default (-1) is to return all ads.
  • opts (QueryOpts.) – Additional flags for the query; these may affect the behavior of the condor_schedd.
Returns:

ClassAds representing the matching jobs.

Return type:

list[ClassAd]

xquery(requirements='true', projection=[], limit=-1, opts=htcondor._htcondor.QueryOpts.Default, name=None) → QueryIterator :

Query the condor_schedd daemon for jobs.

As opposed to query(), this returns an iterator, meaning only one ad is buffered in memory at a time.

Parameters:
  • requirements (str or ExprTree) – provides a constraint for filtering out jobs. It defaults to 'true'.
  • projection (list[str]) – The attributes to return; an empty list (the default) signifies all attributes.
  • limit (int) – A limit on the number of matches to return. The default (-1) indicates all matching jobs should be returned.
  • opts (QueryOpts) – Additional flags for the query, from QueryOpts.
  • name (str) – A tag name for the returned query iterator. This string will always be returned from the QueryIterator.tag() method of the returned iterator. The default value is the condor_schedd’s name. This tag is useful to identify different queries when using the poll() function.
Returns:

An iterator for the matching job ads

Return type:

QueryIterator

act(action, job_spec, reason=None) → object :

Change status of job(s) in the condor_schedd daemon. The return value is a ClassAd object describing the number of jobs changed.

This will throw an exception if no jobs are matched by the constraint.

Parameters:
  • action (JobAction) – The action to perform; must be of the enum JobAction.
  • job_spec (list[str] or str) – The job specification. It can either be a list of job IDs or a string specifying a constraint. Only jobs matching this description will be acted upon.
  • reason (str) – The reason for the action. If omitted, the reason will be “Python-initiated action”.
edit(job_spec, attr, value) → None :

Edit one or more jobs in the queue.

This will throw an exception if no jobs are matched by the job_spec constraint.

Parameters:
  • job_spec (list[str] or str) – The job specification. It can either be a list of job IDs or a string specifying a constraint. Only jobs matching this description will be acted upon.
  • attr (str) – The name of the attribute to edit.
  • value (str or ExprTree) – The new value of the attribute. It should be a string, which will be converted to a ClassAd expression, or an ExprTree object. Be mindful of quoting issues; to set the value to the string foo, one would set the value to ''foo''
history(requirements, projection, match=-1, since=None) → HistoryIterator :

Fetch history records from the condor_schedd daemon.

Parameters:
  • requirements – Query constraint; only jobs matching this constraint will be returned; defaults to 'true'.
  • projection (list[str]) – Attributes that are to be included for each returned job. The empty list causes all attributes to be included.
  • match (int) – An limit on the number of jobs to include; the default (-1) indicates to return all matching jobs.
Returns:

All matching ads in the Schedd history, with attributes according to the projection keyword.

Return type:

HistoryIterator

submit(ad, count=1, spool=False, ad_results=None) → int :

Submit one or more jobs to the condor_schedd daemon.

This method requires the invoker to provide a ClassAd for the new job cluster; such a ClassAd contains attributes with different names than the commands in a submit description file. As an example, the stdout file is referred to as output in the submit description file, but Out in the ClassAd.

Hint

To generate an example ClassAd, take a sample submit description file and invoke:

condor_submit -dump <filename> [cmdfile]

Then, load the resulting contents of <filename> into Python.

Parameters:
  • ad (ClassAd) – The ClassAd describing the job cluster.
  • count (int) – The number of jobs to submit to the job cluster. Defaults to 1.
  • spool (bool) – If True, the clinent inserts the necessary attributes into the job for it to have the input files spooled to a remote condor_schedd daemon. This parameter is necessary for jobs submitted to a remote condor_schedd that use HTCondor file transfer.
  • ad_results (list[ClassAd]) – If set to a list, the list object will contain the job ads resulting from the job submission. These are needed for interacting with the job spool after submission.
Returns:

The newly created cluster ID.

Return type:

int

submitMany(cluster_ad, proc_ads, spool=False, ad_results=None) → int :

Submit multiple jobs to the condor_schedd daemon, possibly including several distinct processes.

Parameters:
  • cluster_ad (ClassAd) – The base ad for the new job cluster; this is the same format as in the submit() method.
  • proc_ads (list) – A list of 2-tuples; each tuple has the format of (proc_ad, count). For each list entry, this will result in count jobs being submitted inheriting from both cluster_ad and proc_ad.
  • spool (bool) – If True, the clinent inserts the necessary attributes into the job for it to have the input files spooled to a remote condor_schedd daemon. This parameter is necessary for jobs submitted to a remote condor_schedd that use HTCondor file transfer.
  • ad_results (list[ClassAd]) – If set to a list, the list object will contain the job ads resulting from the job submission. These are needed for interacting with the job spool after submission.
Returns:

The newly created cluster ID.

Return type:

int

spool(ad_list) → None :

Spools the files specified in a list of job ClassAds to the condor_schedd.

Parameters:ad_list (list[ClassAds]) – A list of job descriptions; typically, this is the list filled by the ad_results argument of the submit() method call.
Raises:RuntimeError – if there are any errors.
refreshGSIProxy(cluster, proc, proxy_filename, lifetime) → int :

Refresh the GSI proxy of a job; the job’s proxy will be replaced the contents of the provided proxy_filename.

Note

Depending on the lifetime of the proxy in proxy_filename, the resulting lifetime may be shorter than the desired lifetime.

Parameters:
  • cluster (int) – Cluster ID of the job to alter.
  • proc (int) – Process ID of the job to alter.
  • proxy_filename (str) – The name of the file containing the new proxy for the job.
  • lifetime (int) – Indicates the desired lifetime (in seconds) of the delegated proxy. A value of 0 specifies to not shorten the proxy lifetime. A value of -1 specifies to use the value of configuration variable DELEGATE_JOB_GSI_CREDENTIALS_LIFETIME.
negotiate(owner, ad={}) → ScheddNegotiate :

Begin a negotiation cycle with the remote schedd for a given user.

Note

The returned ScheddNegotiate additionally serves as a context manager, automatically destroying the negotiation session when the context is left.

Parameters:accounting_name (str) – Determines which user the client will start negotiating with.
Returns:An iterator which yields resource request ClassAds from the condor_schedd. Each resource request represents a set of jobs that are next in queue for the schedd for this user.
Return type:ScheddNegotiate
reschedule() → None :

Send reschedule command to the schedd.

class htcondor.ScheddNegotiate

The ScheddNegotiate class represents an ongoing negotiation session with a schedd. It is a context manager, returned by the negotiate() method.

sendClaim(claim, offer, request={}) → None :

Send a claim to the schedd; if possible, the schedd will activate this and run one or more jobs.

Parameters:
  • claim (str) – The claim ID, typically from the Capability attribute in the corresponding Startd’s private ad.
  • offer (ClassAd) – A description of the resource claimed (typically, the machine’s ClassAd).
  • request (ClassAd) – The resource request this claim is responding to; if not provided (default), the Schedd will decide which job receives this resource.
disconnect() → None :

Disconnect from this negotiation session. This can also be achieved by exiting the context.

class htcondor.JobAction

An enumeration describing the actions that may be performed on a job in queue.

The values of the enumeration are:

Hold

Put a job on hold, vacating a running job if necessary. A job will stay in the hold state until explicitly acted upon by the admin or owner.

Release

Release a job from the hold state, returning it to Idle.

Suspend

Suspend the processes of a running job (on Unix platforms, this triggers a SIGSTOP). The job’s processes stay in memory but no longer get scheduled on the CPU.

Continue

Continue a suspended jobs (on Unix, SIGCONT). The processes in a previously suspended job will be scheduled to get CPU time again.

Remove

Remove a job from the Schedd’s queue, cleaning it up first on the remote host (if running). This requires the remote host to acknowledge it has successfully vacated the job, meaning Remove may not be instantaneous.

RemoveX

Immediately remove a job from the schedd queue, even if it means the job is left running on the remote resource.

Vacate

Cause a running job to be killed on the remote resource and return to idle state. With Vacate, jobs may be given significant time to cleanly shut down.

VacateFast

Vacate a running job as quickly as possible, without providing time for the job to cleanly terminate.

class htcondor.TransactionFlags

Enumerated flags affecting the characteristics of a transaction.

The values of the enumeration are:

NonDurable

Non-durable transactions are changes that may be lost when the condor_schedd crashes. NonDurable is used for performance, as it eliminates extra fsync() calls.

SetDirty

This marks the changed ClassAds as dirty, causing an update notification to be sent to the condor_shadow and the condor_gridmanager, if they are managing the job.

ShouldLog

Causes any changes to the job queue to be logged in the relevant job event log.

class htcondor.QueryOpts

Enumerated flags sent to the condor_schedd during a query to alter its behavior.

The values of the enumeration are:

Default

Queries should use all default behaviors.

AutoCluster

Instead of returning job ads, return an ad per auto-cluster.

GroupBy
DefaultMyJobsOnly
SummaryOnly
IncludeClusterAd
class htcondor.BlockingMode

An enumeration that controls the behavior of query iterators once they are out of data.

The values of the enumeration are:

Blocking

Sets the iterator to block until more data is available.

NonBlocking

Sets the iterator to return immediately if additional data is not available.

class htcondor.HistoryIterator

An iterator over ads in the history produced by Schedd.history().

class htcondor.QueryIterator

An iterator class for managing results of the Schedd.query() and Schedd.xquery() methods.

nextAdsNonBlocking() → list :

Retrieve as many ads are available to the iterator object.

If no ads are available, returns an empty list. Does not throw an exception if no ads are available or the iterator is finished.

Returns:Zero-or-more job ads.
Return type:list[ClassAd]
tag() → str :

Retrieve the tag associated with this iterator; when using the poll() method, this is useful to distinguish multiple iterators.

Returns:The query’s tag.
done() → bool :
Returns:True if the iterator is finished; False otherwise.
Return type:bool
watch() → int :

Returns an inotify-based file descriptor; if this descriptor is given to a select() instance, select will indicate this file descriptor is ready to read whenever there are more jobs ready on the iterator.

If inotify is not available on this platform, this will return -1.

Returns:A file descriptor associated with this query.
Return type:int
htcondor.poll(queries, timeout_ms=20000) → BulkQueryIterator :

Wait on the results of multiple query iterators.

This function returns an iterator which yields the next ready query iterator. The returned iterator stops when all results have been consumed for all iterators.

Parameters:active_queries (list[QueryIterator]) – Query iterators as returned by xquery().
Returns:An iterator producing the ready QueryIterator.
Return type:BulkQueryIterator
class htcondor.BulkQueryIterator

Returned by poll(), this iterator produces a sequence of QueryIterator objects that have ads ready to be read in a non-blocking manner.

Once there are no additional available iterators, poll() must be called again.

Submitting Jobs

class htcondor.Submit(input=None)

An object representing a job submit description. It uses the same submit language as condor_submit.

The submit description contains key = value pairs and implements the python dictionary protocol, including the get, setdefault, update, keys, items, and values methods.

Parameters:input (dict or str) – key = value pairs as a dictionary or string for initializing the submit description. If omitted, the submit object is initially empty.
queue(txn, count=0, ad_results=None) → int :

Submit the current object to a remote queue.

Parameters:
  • txn (Transaction) – An active transaction object (see Schedd.transaction()).
  • count (int) – The number of jobs to create (defaults to 1).
  • ad_results – A list to receive the ClassAd resulting from this submit. As with Schedd.submit(), this is often used to later spool the input files.
Returns:

The ClusterID of the submitted job(s).

Return type:

int

Raises:

RuntimeError – if the submission fails.

queue_with_itemdata(txn, count=1, from=None) → SubmitResult :

Submit the current object to a remote queue.

Parameters:
  • txn (Transaction) – An active transaction object (see Schedd.transaction()).
  • count (int) – A queue count for each item from the iterator, defaults to 1.
  • from – an iterator of strings or dictionaries containing the itemdata for each job as in queue in or queue from.
Returns:

a SubmitResult, containing the cluster ID, cluster ClassAd and range of Job ids Cluster ID of the submitted job(s).

Return type:

SubmitResult

Raises:

RuntimeError – if the submission fails.

expand(attr) → str :

Expand all macros for the given attribute.

Parameters:attr (str) – The name of the relevant attribute.
Returns:The value of the given attribute; all macros are expanded.
Return type:str
jobs(count=0, from=None, clusterid=1, procid=0, qdate=0, owner='') → SubmitJobsIterator :

Turn the current object into a sequence of simulated job ClassAds

Parameters:
  • count (int) – the queue count for each item in the from list, defaults to 1
  • from – a iterator of strings or dictionaries containing the itemdata for each job e.g. ‘queue in’ or ‘queue from’
  • clusterid (int) – the value to use for ClusterId when making job ads, defaults to 1
  • procid (int) – the initial value for ProcId when making job ads, defaults to 0
  • qdate (str) – a UNIX timestamp value for the QDATE attribute of the jobs, 0 means use the current time.
  • owner (str) – a string value for the Owner attribute of the job
Returns:

An iterator for the resulting job ads.

Raises:

RuntimeError – if valid job ads cannot be made

procs(count=0, from=None, clusterid=1, procid=0, qdate=0, owner='') → SubmitJobsIterator :

Turn the current object into a sequence of simulated job proc ClassAds. The first ClassAd will be the cluster ad plus a ProcId attribute

Parameters:
  • count (int) – the queue count for each item in the from list, defaults to 1
  • from – a iterator of strings or dictionaries containing the foreach data e.g. ‘queue in’ or ‘queue from’
  • clusterid (int) – the value to use for ClusterId when making job ads, defaults to 1
  • procid (int) – the initial value for ProcId when making job ads, defaults to 0
  • qdate (str) – a UNIX timestamp value for the QDATE attribute of the jobs, 0 means use the current time.
  • owner (str) – a string value for the Owner attribute of the job
Returns:

An iterator for the resulting job ads.

Raises:

RuntimeError – if valid job ads cannot be made

itemdata(qargs='') → QueueItemsIterator :

Create an iterator over itemdata derived from a queue statement.

For example itemdata("matching *.dat") would return an iterator of filenames that end in .dat from the current directory. This is the same iterator used by condor_submit when processing QUEUE statements.

Parameters:queue (str) – a submit queue statement, or the arguments to a submit queue statement.
Returns:An iterator for the resulting items
getQArgs() → str :

Returns arguments specified in the QUEUE statement passed to the contructor. These are the arguments that will be used by the Submit.queue() and Submit.queue_with_itemdata() methods if not overridden by arguments to those methods.

setQArgs(args) → None :

Sets the arguments to be used by subsequent calls to the Submit.queue() and Submit.queue_with_itemdata() methods if not overridden by arguments to those methods.

Parameters:args (str) – The arguments to pass to the QUEUE statement.
class htcondor.QueueItemsIterator

An iterator over itemdata produced by Submit.itemdata().

class htcondor.SubmitResult
cluster() → int :
Returns:the ClusterID of the submitted jobs.
Return type:int
clusterad() → ClassAd :
Returns:the cluster Ad of the submitted jobs.
Return type:int
first_proc() → int :
Returns:the first ProcID of the submitted jobs.
Return type:int
num_procs() → int :
Returns:the number of submitted jobs.
Return type:int

Interacting with Negotiators

class htcondor.Negotiator(ad)

This class provides a query interface to the condor_negotiator. It primarily allows one to query and set various parameters in the fair-share accounting.

Parameters:ad (ClassAd) – A ClassAd describing the claim and the condor_negotiator location. If omitted, the default pool negotiator is assumed.
deleteUser(user) → None :

Delete all records of a user from the Negotiator’s fair-share accounting.

Parameters:user (str) – A fully-qualified user name (USER@DOMAIN).
getPriorities(rollup) → list :

Retrieve the pool accounting information, one per entry. Returns a list of accounting ClassAds.

Parameters:rollup (bool) – Set to True if accounting information, as applied to hierarchical group quotas, should be summed for groups and subgroups.
Returns:A list of accounting ads, one per entity.
Return type:list[ClassAd]
getResourceUsage(user) → list :

Get the resources (slots) used by a specified user.

Parameters:user (str) – A fully-qualified user name (USER@DOMAIN).
Returns:List of ads describing the resources (slots) in use.
Return type:list[ClassAd]
resetAllUsage() → None :

Reset all usage accounting. All known user records in the negotiator are deleted.

resetUsage(user) → None :

Reset all usage accounting of the specified user.

Parameters:user (str) – A fully-qualified user name (USER@DOMAIN).
setBeginUsage(user, value) → None :

Manually set the time that a user begins using the pool.

Parameters:
  • user (str) – A fully-qualified user name (USER@DOMAIN).
  • value (int) – The Unix timestamp of initial usage.
setLastUsage(user, value) → None :

Manually set the time that a user last used the pool.

Parameters:
  • user (str) – A fully-qualified user name (USER@DOMAIN).
  • value (int) – The Unix timestamp of last usage.
setFactor(user, factor) → None :

Set the priority factor of a specified user.

Parameters:
  • user (str) – A fully-qualified user name (USER@DOMAIN).
  • factor (float) – The priority factor to be set for the user; must be greater-than or equal-to 1.0.
setPriority(user, prio) → None :

Set the real priority of a specified user.

Parameters:
  • user (str) – A fully-qualified user name (USER@DOMAIN).
  • prio (float) – The priority to be set for the user; must be greater-than 0.0.
setUsage(user, usage) → None :

Set the accumulated usage of a specified user.

Parameters:
  • user (str) – A fully-qualified user name (USER@DOMAIN).
  • usage (float) – The usage, in hours, to be set for the user.

Managing Starters and Claims

class htcondor.Startd(ad=None)

A class that represents a Startd.

Parameters:ad (ClassAd) – A ClassAd describing the claim and the startd location. If omitted, the local startd is assumed.
drainJobs(drain_type=0, resume_on_completion=False, check_expr='true', start_expr='false') → str :

Begin draining jobs from the startd.

Parameters:
  • drain_type (DrainTypes) – How fast to drain the jobs. Defaults to DRAIN_GRACEFUL if not specified.
  • resume_on_completion (bool) – Whether the startd should start accepting jobs again once draining is complete. Otherwise, it will remain in the drained state. Defaults to False.
  • check_expr (str or ExprTree) – An expression string that must evaluate to true for all slots for draining to begin. Defaults to 'true'.
  • start_expr (str or ExprTree) – The expression that the startd should use while draining.
Returns:

An opaque request ID that can be used to cancel draining via Startd.cancelDrainJobs()

Return type:

str

cancelDrainJobs(request_id='') → None :

Cancel a draining request.

Parameters:request_id (str) – Specifies a draining request to cancel. If not specified, all draining requests for this startd are canceled.
class htcondor.DrainTypes

Draining policies that can be sent to a condor_startd.

The values of the enumeration are:

Fast
Graceful
Quick
class htcondor.Claim(ad)

The Claim class provides access to HTCondor’s Compute-on-Demand facilities. The class represents a claim of a remote resource; it allows the user to manually activate a claim (start a job) or release the associated resources.

The claim comes with a finite lifetime - the lease. The lease may be extended for as long as the remote resource (the Startd) allows.

To create a Claim object for a given remote resource, you need to provide an ad which contains a description of the resource, as returned by Collector.locate().

This only stores the remote resource’s location; it is not contacted until requestCOD() is invoked.

Parameters:ad (ClassAd) – An ad describing the Claim (optionally) and a Startd location.
requestCOD(constraint=None, lease_duration=-1) → None :

Request a claim from the condor_startd represented by this object.

On success, the Claim object will represent a valid claim on the remote startd; other methods, such as activate() should now function.

Parameters:
  • constraint (str) – ClassAd expression that pecifies which slot in the startd should be claimed. Defaults to 'true', which will result in the first slot becoming claimed.
  • lease_duration (int) – Indicates how long the claim should be valid. Defaults to -1, which indicates to lease the resource for as long as the Startd allows.
activate(ad) → None :

Activate a claim using a given job ad.

Parameters:ad – Description of the job to launch; this uses similar, but not identical attribute names as condor_submit. See the HTCondor manual for a description of the job language.
release(vacate_type=htcondor._htcondor.VacateTypes.Graceful) → None :

Release the remote condor_startd from this claim; shut down any running job.

Parameters:vacate_type (VacateTypes) – The type of vacate to perform for the running job.
suspend() → None :

Temporarily suspend the remote execution of the COD application. On Unix systems, this is done using SIGSTOP.

resume() → None :

Resume the temporarily suspended execution. On Unix systems, this is done using SIGCONT.

renew() → None :

Renew the lease on an existing claim. The renewal should last for the value of the lease_duration.

deactivate(vacate_type=htcondor._htcondor.VacateTypes.Graceful) → None :

Deactivate a claim; shuts down the currently running job, but holds onto the claim for future activation.

Parameters:vacate_type (VacateTypes) – The type of vacate to perform for the running job.
delegateGSIProxy(filename=None) → None :

Send an X509 proxy credential to an activated claim.

Parameters:filename (str) – Filename of the X509 proxy to send to the active claim.
class htcondor.VacateTypes

Vacate policies that can be sent to a condor_startd.

The values of the enumeration are:

Fast
Graceful

Security Management

class htcondor.SecMan(arg1)

A class that represents the internal HTCondor security state.

If a security session becomes invalid, for example, because the remote daemon restarts, reuses the same port, and the client continues to use the session, then all future commands will fail with strange connection errors. This is the only mechanism to invalidate in-memory sessions.

The SecMan can also behave as a context manager; when created, the object can be used to set temporary security configurations that only last during the lifetime of the security object.

invalidateAllSessions() → None :

Invalidate all security sessions. Any future connections to a daemon will cause a new security session to be created.

ping(ad, command='DC_NOP') → ClassAd :

Perform a test authorization against a remote daemon for a given command.

Parameters:
  • ad (str or ClassAd) – The ClassAd of the daemon as returned by Collector.locate(); alternately, the sinful string can be given directly as the first parameter.
  • command – The DaemonCore command to try; if not given, 'DC_NOP' will be used.
Returns:

An ad describing the results of the test security negotiation.

Return type:

ClassAd

getCommandString(command_int) → str :

Return the string name corresponding to a given integer command.

Parameters:command_int (int) – The integer command to get the string name of.
setConfig(key, value) → None :

Set a temporary configuration variable; this will be kept for all security sessions in this thread for as long as the SecMan object is alive.

Parameters:
  • key (str) – Configuration key to set.
  • value (str) – Temporary value to set.
setGSICredential(filename) → None :

Set the GSI credential to be used for security negotiation.

Parameters:filename (str) – File name of the GSI credential.
setPoolPassword(new_pass) → None :

Set the pool password.

Parameters:new_pass (str) – Updated pool password to use for new security negotiations.
setTag(tag) → None :

Set the authentication context tag for the current thread.

All security sessions negotiated with the same tag will only be utilized when that tag is active.

For example, if thread A has a tag set to 'Joe' and thread B has a tag set to 'Jane', then all security sessions negotiated for thread A will not be used for thread B.

Parameters:tag (str) – New tag to set.

Reading Job Events

class htcondor.JobEventLog(filename)

Reads job event (user) logs.

Create an instance of the JobEventLog class.

Parameters:filename (str) – A file containing a job event (user) log.
events(stop_after) → object :

Return an iterator over JobEvent from the filename given in the constructor.

Parameters:stop_after (int) – After how many seconds should the iterator stop waiting for new events? If None, wait forever. If 0, never wait.
close() → None :

Closes any open underlying file. This object will no longer iterate.

class htcondor.JobEvent

Represents a single job event from the job event log. Use JobEventLog to get an iterator over the job events from a file.

Because all events have type, cluster, proc, and timestamp, those are accessed via attributes (see below).

The rest of the information in the JobEvent can be accessed by key. JobEvent behaves like a read-only Python dict, with get, keys, items, and values methods, and support len and in (if "attribute" in job_event, for example).

Attention

Although the attribute type is a JobEventType type, when acting as dictionary, a JobEvent object returns types as if it were a ClassAd, so comparisons to enumerated values must use the == operator. (No current event type has ExprTree values.)

type

The event type.

Return type:JobEventType
cluster

The clusterid of the job the event is for.

Return type:int
proc

The procid of the job the event is for.

Return type:int
timestamp

The timestamp of the event.

Return type:str
get(key, default=None) → object :

As dict.get().

keys() → list :

As dict.keys().

values() → list :

As dict.values().

items() → list :

As dict.items().

class htcondor.JobEventType

The type event of a user log event; corresponds to ULogEventNumber in the C++ source.

The values of the enumeration are:

SUBMIT
EXECUTE
EXECUTABLE_ERROR
CHECKPOINTED
JOB_EVICTED
JOB_TERMINATED
IMAGE_SIZE
SHADOW_EXCEPTION
GENERIC
JOB_ABORTED
JOB_SUSPENDED
JOB_UNSUSPENDED
JOB_HELD
JOB_RELEASED
NODE_EXECUTE
NODE_TERMINATED
POST_SCRIPT_TERMINATED
GLOBUS_SUBMIT
GLOBUS_SUBMIT_FAILED
GLOBUS_RESOURCE_UP
GLOBUS_RESOURCE_DOWN
REMOTE_ERROR
JOB_DISCONNECTED
JOB_RECONNECTED
JOB_RECONNECT_FAILED
GRID_RESOURCE_UP
GRID_RESOURCE_DOWN
GRID_SUBMIT
JOB_AD_INFORMATION
JOB_STATUS_UNKNOWN
JOB_STATUS_KNOWN
JOB_STAGE_IN
JOB_STAGE_OUT
ATTRIBUTE_UPDATE
PRESKIP
CLUSTER_SUBMIT
CLUSTER_REMOVE
FACTORY_PAUSED
FACTORY_RESUMED
NONE
FILE_TRANSFER

HTCondor Configuration

htcondor.param = <htcondor._htcondor._Param object>

Provides dictionary-like access the HTCondor configuration.

An instance of _Param. Upon importing the htcondor module, the HTCondor configuration files are parsed and populate this dictionary-like object.

htcondor.reload_config() → None :

Reload the HTCondor configuration from disk.

class htcondor.RemoteParam(ad)

The RemoteParam class provides a dictionary-like interface to the configuration of an HTCondor daemon. The get, setdefault, update, keys, items, and values methods of this class have the same semantics as a Python dictionary.

Parameters:ad (ClassAd) – An ad containing the location of the remote daemon.
refresh() → None :

Rebuilds the dictionary based on the current configuration of the daemon.

htcondor.platform() → str :

Returns the platform of HTCondor this module is running on.

htcondor.version() → str :

Returns the version of HTCondor this module is linked against.

HTCondor Logging

htcondor.enable_debug() → None :

Enable debugging output from HTCondor, where output is sent to stderr. The logging level is controlled by the TOOL_DEBUG parameter.

htcondor.enable_log() → None :

Enable debugging output from HTCondor, where output is sent to a file. The log level is controlled by the parameter TOOL_DEBUG, and the file used is controlled by TOOL_LOG.

htcondor.log(level, msg) → None :

Log a message using the HTCondor logging subsystem.

Parameters:
  • level (LogLevel) – The log category and formatting indicator. Multiple LogLevel enum attributes may be OR’d together.
  • msg (str) – A message to log.
class htcondor.LogLevel

The log level attribute to use with log(). Note that HTCondor mixes both a class (debug, network, all) and the header format (Timestamp, PID, NoHeader) within this enumeration.

The values of the enumeration are:

Always
Audit
Config
DaemonCore
Error
FullDebug
Hostname
Job
Machine
Network
NoHeader
PID
Priv
Protocol
Security
Status
SubSecond
Terse
Timestamp
Verbose

Esoteric Functionality

htcondor.send_command(ad, dc, target) → None :

Send a command to an HTCondor daemon specified by a location ClassAd.

Parameters:
  • ad (ClassAd) – Specifies the location of the daemon (typically, found by using Collector.locate()).
  • dc (DaemonCommands) – A command type
  • target (str) – An additional command to send to a daemon. Some commands require additional arguments; for example, sending DaemonOff to a condor_master requires one to specify which subsystem to turn off.
class htcondor.DaemonCommands

An enumeration of various state-changing commands that can be sent to a HTCondor daemon using send_command().

The values of the enumeration are:

DaemonOff
DaemonOffFast
DaemonOffPeaceful
DaemonsOff
DaemonsOffFast
DaemonsOffPeaceful
OffFast
OffForce
OffGraceful
OffPeaceful
Reconfig
Restart
RestartPeacful
SetForceShutdown
SetPeacefulShutdown
htcondor.send_alive([ ad=None, pid=None, timeout=None) → None :

Send a keep alive message to an HTCondor daemon.

This is used when the python process is run as a child daemon under the condor_master.

Parameters:
  • ad (ClassAd) – A ClassAd specifying the location of the daemon. This ad is typically found by using Collector.locate().
  • pid (int) – The process identifier for the keep alive. The default value of None uses the value from os.getpid().
  • timeout (int) – The number of seconds that this keep alive is valid. If a new keep alive is not received by the condor_master in time, then the process will be terminated. The default value is controlled by configuration variable NOT_RESPONDING_TIMEOUT.
htcondor.set_subsystem(subsystem, type=htcondor._htcondor.SubsystemType(16)) → None :

Set the subsystem name for the object.

The subsystem is primarily used for the parsing of the HTCondor configuration file.

Parameters:
  • name (str) – The subsystem name.
  • daemon_type (SubsystemType) – The HTCondor daemon type. The default value of Auto infers the type from the name parameter.
class htcondor.SubsystemType

An enumeration of known subsystem names.

The values of the enumeration are:

Collector
Daemon
Dagman
GAHP
Job
Master
Negotiator
Schedd
Shadow
SharedPort
Startd
Starter
Submit
Tool