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

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



Thanks for your detailed response.


You are right, in the early morning hours I missed the distinction between ‘regexp’ and ‘regexps’  in the different manual references I had open.


I tried it like this for Windows CMD shell:

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


It parses without error, but doesn’t return any matches.


Following Christoph’s example I also tried:

condor_q -nobatch -const “ “lidarMatching” == regexps(“”(lidarMatching)””, JobBatchName, “”\1””) “


and similarly didn’t return any matches.  I will do some more work with it.


That quote about regular expressions is new to me, but I like it!


We have a commercial product with basic integration of HTCondor for distributed processing.  I’m not a programmer, but I pick up things here and there to close support cases when the developers don’t have time for ‘nice to have’.  The GUI for our product will read a CondorSubmit.conf from the local install directory of the product, and by this mechanism we can inject Requirements into the job files.  I was trying to implement a requirement exactly like your MyCompanyJobType automatically by parsing the JobBatchName, but I could manually add it as you have shown.  Or better yet escalate it with the GUI developers.





From: HTCondor-users <htcondor-users-bounces@xxxxxxxxxxx> On Behalf Of Greg Thain
Sent: Wednesday, November 6, 2019 9:19 AM
To: htcondor-users@xxxxxxxxxxx
Subject: Re: [HTCondor-users] Regular Expressions in -constraint


This email is not from Hexagon’s Office 365 instance. Please be careful while clicking links, opening attachments, or replying to this email.


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"'