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

Re: [HTCondor-users] Regular Expressions in -constraint

On 11/6/19 12:01 AM, O'NEAL Mark via HTCondor-users wrote:



I’m trying out the regular _expression_ functionality of HTCondor’s ClassAd mechanism, and have a question for some behavior I don’t yet understand.


As background, I would eventually like to utilize a portion of the JobBatchName attribute as a Requirement for matching jobs with machines.


To test how this might work, I’m using condor_q to learn.  HTCondor 8.8.4 running on Windows.

Debugging this sort of thing with condor_q is an excellent way to proceed.

The surprise here is that the HTCondor classad "regexp" function, only returns true or false, it doesn't return a value.

I try to confirm that I am capturing ‘lidarMatching’ in the way I expect the regexp should be working:

condor_q -nobatch -constraint " regexp(""([0-9]+)(_)([A-Za-z]+)"", JobBatchName, ""\3"") == ""lidarMatching"" "

So, the regexp(...) part of this _expression_ is evaluating to true.  classads also provides the regexps and replace functions, which can return the submatch.  So, something like this might work (season your shell quoting to taste)

$ condor_q -nobatch -const ' "lidarMatching" == regexps("^[0-9]{12}_([A-Za-z]+)", JobBatchName, "\\1") '

Now, you know what is said about regular expressions:

"Some people, when confronted with a problem, think “I know, I'll use regular expressions.”   Now they have two problems."

If possible, I would address this problem with a custom job attribute.  If you can add into your job submit file something like

+MyCompanyNameJobType = "lidarMatching"

(Note the prefix is just to avoid name collisions with anything else).

Then the query is just condor_q -const 'MyCompanyNameJobType == "lidarMatching"'