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

Re: [HTCondor-users] behaviour of if on 'false' /macro return



Sorry, overdid that.  In fact you only need to eval the if clause once.  So this works

EVALMACRO tmp.match regexp("OpSysAndVer == \"SL6\"",unparse(Requirements))
if $(tmp.match)
  ....

And so does this

tmp.match = regexp("OpSysAndVer == \"SL6\"",unparse(Requirements))
if $EVAL(tmp.match)
  ....

But this does not work

if regexp("OpSysAndVer == \"SL6\"",unparse(Requirements))
   ...

-tj

-----Original Message-----
From: John M Knoeller 
Sent: Monday, November 5, 2018 3:38 PM
To: htcondor-users@xxxxxxxxxxx
Subject: RE: [HTCondor-users] behaviour of if on 'false' /macro return

Evaluation is in the order that the statements appear in the .rules file.  

your transform isn't working the way you want it to because you are using an invalid if statement.  
You MUST use a temporary variable for complex if statements.  
If only allows a literal true, false, 1 or 0 after $() expansion, anything else will cause a parse error or incorrect behavior.
You can force evaluation of a temporary variable to happen during $() expansion by using $EVAL() or $INT()

So this will work

EVALMACRO tmp.match regexp("OpSysAndVer == \"SL6\"",unparse(Requirements))
if $EVAL(tmp.match)
  ...


Also the +Attr syntax is for submit files only,
in a job transform just use Attr.  

This
  SET SingularityImage "/foo/sl6"

NOT this
  SET +SingularityImage "/foo/sl6"

-tj

-----Original Message-----
From: HTCondor-users <htcondor-users-bounces@xxxxxxxxxxx> On Behalf Of Thomas Hartmann
Sent: Friday, November 2, 2018 6:41 AM
To: htcondor-users@xxxxxxxxxxx
Subject: [HTCondor-users] behaviour of if on 'false' /macro return

Hi all,

a short question how if/else in the old-style syntax handles false
returns from macros:

~~> I have a set of class ads 'my.classads.{sl6,el7}' (see attachement)
which I want to transform with 'my.rule'

my.rule has an if/else on the return of a regexp(), that is supposed to
return true when finding 'SL6' and false else. Applying my.rule to the
ClassAds with the stringified requirements containing 'SL6' works fine [1].
But if I apply the same rule to a string where regexp does not match,
the whole transform just fails [2] - where I would have expected that
the rule would just take the else branch.

To test if regexp() does not return ERROR on a non-string argument or
so, in a cross-check 'my.rule.set' just sets the result of regexp() as
ClassAd [3].
For
  my.classads.{sl6,el7}
the return values are a boolean
  WhatIsRegexp = {true,false}
as far as I can see ~~> and my.rule should take the else-branch on
false, or?

If the target is not a string but an ad, EVALSET regexp() ends up as
undefined [4], which I suppose is the way for EVAL* to interpolate ERROR.

Long story short: why does the transform fail on 'if false'? ;)

Cheers and thanks for any hints,
  Thomas



[1]
> condor_transform_ads -verbose -rule /tmp/my.rule /tmp/my.classads.sl6
EVALMACRO tmp.MyRequirements to
regexps("(.*)SL6(.*)",unparse(Requirements),"\\1CentOS7\\2")
          tmp.MyRequirements = ( OpSysAndVer == "CentOS7" && (
TARGET.Arch == "X86_64" ) )
SET Requirements to ( OpSysAndVer == "CentOS7" && ( TARGET.Arch ==
"X86_64" ) )
SET +SingularityImage to "/foo/sl6"
+SingularityImage = "/foo/sl6"
DiskUsage = 250000
executable = mypayload.sh
input = mypayload.data
requirements = ( OpSysAndVer == "CentOS7" && ( TARGET.Arch == "X86_64" ) )
universe = vanilla

[2]
> condor_transform_ads -verbose -rule /tmp/my.rule /tmp/my.classads.el7
Transform of ad  failed!

[3]
> condor_transform_ads -verbose -rule /tmp/my.rule.set
/tmp/my.classads.{sl6,el7}

[4]
> condor_transform_ads -verbose -rule
/tmp/my.rule.set.nonstringasregexptarget /tmp/my.classads.el7
...
WhatIsRegexp = undefined