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

Re: [HTCondor-users] transform syntax to build complex ads possible?



I would need to see your actual transform.  this EVALSET statement

EVALSET AccountingGroup = [
  x1 = ifThenElse(cond1, value1,undefined);
  x2 = x1 ?: ifThenElse(cond2, value2, undefined);
  ...
  x<n> = x<n-1>?: ifThenElse(cond<n>, value<n>, default);
]["x<n>"]

is not allowed to span multiple lines.   so the net effect will be 

EVALSET AccountingGroup = [

followed by some statements that do nothing

For your simpler example.

EVALSET TEST = [ a=Project ]["a"]

you say Project is set in submit. Does that mean the job has an attribute called Project?
Because this is an EVALSET,  it would set TEST to the whatever Project evaluates to.

If that is ending up being undefined,  I think the problem here he one of scope.  since Project is not defined in the temporary ad [a=Project] it ends up being undefined when evaluated.  

you can work around this limitation by generating a textual representation  of the _expression_ you want,and then then using SET to change the job.  This works because SET will parse the text as an _expression_.  There are two ways to accomplish this

  EVALMACRO tmp = [a="Project"]["a"]
  SET test = $(tmp)

or

   tmp = [a="Project"]["a"]
   SET test = $STRING(tmp)

note the use of a="Project" rather than a=Project here

-tj


From: HTCondor-users <htcondor-users-bounces@xxxxxxxxxxx> on behalf of Sever, Krunoslav <krunoslav.sever@xxxxxxx>
Sent: Friday, October 8, 2021 7:01 AM
To: HTCondor-Users Mail List <htcondor-users@xxxxxxxxxxx>
Subject: Re: [HTCondor-users] transform syntax to build complex ads possible?
 
Hi,

this looks like a useful feature and I tried to use it to break up our IfThenElse() construct in our JobTransform:

eval_set_AccountingGroup = ifThenElse( cond1, \
  value1 \
  ifThenElse(cond2, \
    value2, \
    ...
  ) \
)

As condor_status -limit 1 -af '[a=Name]["a"]' resolves to the Name from the machine ad, I tried the replacement

EVALSET AccountingGroup = [
  x1 = ifThenElse(cond1, value1,undefined);
  x2 = x1 ?: ifThenElse(cond2, value2, undefined);
  ...
  x<n> = x<n-1>?: ifThenElse(cond<n>, value<n>, default);
]["x<n>"]

A reconfig accepted the transform (judging from the D_FULLDEBUG output in SchedLog) but the conditions failed to access job ad to be transformed.

Testing this with a simpler transform like

EVALSET TEST = [ a=Project ]["a"]

set undefined in the transformed job, even though Project is set in the original submit.

Aa an aside, I initially tried with eval_set, where it also reordered the x<i> lines which does not happen with EVALSET.

I assume this is a bug? If so, I'd appreciate a fix somewhere down the line, modifying the current construct is very error-prone...

Maybe it is not even too hard to add a function like

  ifThenElseChain(cond1, val1, ..., condn, valn, default)

This would take care of short-circuiting which my replacement lacks - not too important, but could be nice...

Best
  Kruno

----- Original Message -----
> From: "John M Knoeller" <johnkn@xxxxxxxxxxx>
> To: "HTCondor-Users Mail List" <htcondor-users@xxxxxxxxxxx>
> Sent: Thursday, 7 October, 2021 18:03:28
> Subject: Re: [HTCondor-users] transform syntax to build complex ads possible?

> the GROUP_SORT_EXPR cannot be a classad, because it needs to evaluate to an
> integer
> but the _expression_ can contain one or more classads as part of the _expression_
>
> for example
>
>> condor_status -limit 1 -af '[a=1;b=2]["a"]'
> 1
>> condor_status -limit 1 -af '[a=1;b=2]["b"]'
> 2
>> condor_status -limit 1 -af '[a=1;b=2]["c"]'
> error
>
> In the above [a=1;b=2] declares a classad,  and ["a"]  does a lookup within that
> classad for attribute a.
> the result of evaluation will be 1
>
> -tj
> ________________________________
> From: HTCondor-users <htcondor-users-bounces@xxxxxxxxxxx> on behalf of Thomas
> Hartmann <thomas.hartmann@xxxxxxx>
> Sent: Thursday, October 7, 2021 8:32 AM
> To: HTCondor-Users Mail List <htcondor-users@xxxxxxxxxxx>
> Subject: [HTCondor-users] transform syntax to build complex ads possible?
>
> Hi all,
>
> is it actually possible, to write a a class ad in the new transform
> syntax (i.e., w/o square brackets)?
>
> AFAIS it is no macro/function/... where I can return a value, or?
>
> Background is, that I would like to refactor a `GROUP_SORT_EXPR`, that
> has grown over time into a forest of IfThenElse()'s.
>
> If I get it correctly, a 'macro' in the []-syntax is effectively a
> complex class ad. But I am not sure, if I can evaluate/set a new
> transform-like _expression_ directly into an ad?
>
> Cheers,
>   Thomas
>
>
>
>
> _______________________________________________
> HTCondor-users mailing list
> To unsubscribe, send a message to htcondor-users-request@xxxxxxxxxxx with a
> subject: Unsubscribe
> You can also unsubscribe by visiting
> https://lists.cs.wisc.edu/mailman/listinfo/htcondor-users
>
> The archives can be found at:
> https://lists.cs.wisc.edu/archive/htcondor-users/

--
------------------------------------------------------------------------
Krunoslav Sever            Deutsches Elektronen-Synchrotron (IT-Systems)
                        Ein Forschungszentrum der Helmholtz-Gemeinschaft
                                                            Notkestr. 85
phone:  +49-40-8998-1648                                   22607 Hamburg
e-mail: krunoslav.sever@xxxxxxx                                  Germany
------------------------------------------------------------------------
_______________________________________________
HTCondor-users mailing list
To unsubscribe, send a message to htcondor-users-request@xxxxxxxxxxx with a
subject: Unsubscribe
You can also unsubscribe by visiting
https://lists.cs.wisc.edu/mailman/listinfo/htcondor-users

The archives can be found at:
https://lists.cs.wisc.edu/archive/htcondor-users/