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

Re: [HTCondor-users] comparison operators in job transforms/routes



No I don't really understand why this code does not correctly handle complex conditionals
in IF statements for job transforms.  It appears that it would - assuming the job ad is present, which I think is the case for transforms.

It is possible that the real issue here is undefined or error results cannot be coerced to bool and what is really needed here is just a few more lines of code to handle or report those reasonably.  

-tj





From: HTCondor-users <htcondor-users-bounces@xxxxxxxxxxx> on behalf of Sever, Krunoslav <krunoslav.sever@xxxxxxx>
Sent: Wednesday, September 29, 2021 10:49 AM
To: HTCondor-Users Mail List <htcondor-users@xxxxxxxxxxx>
Subject: Re: [HTCondor-users] comparison operators in job transforms/routes
 
Hm,

interesting - I have been looking into the code in search of the cause:

In condor_utils/config.cpp I found

if ((ec == CIFT_COMPLEX) && ctx.is_context_ex && reinterpret_cast<MACRO_EVAL_CONTEXT_EX&>(ctx).ad) {
                classad::Value val;
                if (reinterpret_cast<MACRO_EVAL_CONTEXT_EX&>(ctx).ad->EvaluateExpr(expr, val)) {
                        bool bval;
                        if (val.IsBooleanValueEquiv(bval)) {
                                return bval;
                        }
                }
        }

The CIFT_COMPLEX case appears to be triggered by the presence of the comparison operator in the _expression_ and it should be true because of

        if (ec == CIFT_COMPLEX) {
                err_reason = "complex conditionals are not supported";
        } else {
        ...

right after that, which is also the only place in the code where the message appears.

So generally it could work, only that the context somehow fails to (sometimes) eval the _expression_ to a bool - I assume the .ad is the job ad here, but I might be wrong.

Do you have an explanation?

Best
  Kruno

----- Original Message -----
> From: "John M Knoeller" <johnkn@xxxxxxxxxxx>
> To: "HTCondor-Users Mail List" <htcondor-users@xxxxxxxxxxx>
> Sent: Wednesday, 29 September, 2021 16:50:45
> Subject: Re: [HTCondor-users] comparison operators in job transforms/routes

> The transform language allows only  true, false, 0, non-zero, and defined after
> if
>
> You need to use EVALMACRO  to evaluate a more complex conditional _expression_ and
> resolve it to a simple literal  true, false, 0, or non-zero value like this
>
> EVALMACRO more_than_2_cpus = (RequestCpus ?: 1) > 2
> if $(more_than_2_cpus)
>    # conditional statements
> endif
>
> I'm a bit surprised that you don't see an error message for all cases, the only
> time it is valid to use =
> on the same line as the if is when doing version comparison, so I'm guessing
> that the parser is confused.
>
> -tj
> ________________________________
> From: HTCondor-users <htcondor-users-bounces@xxxxxxxxxxx> on behalf of Thomas
> Hartmann <thomas.hartmann@xxxxxxx>
> Sent: Wednesday, September 29, 2021 8:15 AM
> To: HTCondor-Users Mail List <htcondor-users@xxxxxxxxxxx>
> Subject: [HTCondor-users] comparison operators in job transforms/routes
>
> Hi all,
>
> I am trying to write a job transform, where I would like to make a case
> comparison like [1].
>
> My problem is right now, that the ad's value comparison fails for the
> condition with
>
>    > job_transforms: ERROR applying transform DESYMCOREReweight
> (err=-3,rval=-1,msg=RequestCpus >= 2 is not a valid if condition)
>
> I tried $(var) like `if $(RequestCpus) >= 2` as well, but the ad (to be
> evaluated) seems to be too compound for being a <simple condition>
>
>   > job_transforms: ERROR applying transform DESYMCOREReweight
> (err=-3,rval=-1,msg=$(RequestCpus) >= 2 is not a valid if condition
> because complex conditionals are not supported)
>
> assuming that syntax is the same for job transforms/routes with 8.9+ and
> submissions [2]
>
> Interestingly, no error is thrown when the integer of requested cores
> and the integer in the comparison are the same, i.e., `RequestCpus >= 3`
> with `request_cpus = 3`.
>
> Maybe I am missing something obvious here, but in principle it should
> work to do comparison operations in job transforms conditionals, or?
>
> Installed packages are [3]
>
> Cheers,
>   Thomas
>
>
> [1]
> JOB_TRANSFORM_NAMES = $(JOB_TRANSFORM_NAMES), MCOREReweight
>
> JOB_TRANSFORM_MCOREReweight @=end
>
> if RequestCpus >= 2
>   EVALSET MYAcctGroup = $(MYAcctGroup).mcore
> else
>   EVALSET MYAcctGroup = $(MYAcctGroup).score
> endif
>
> @end
>
>
> [2]
> https://htcondor.readthedocs.io/en/latest/users-manual/submitting-a-job.html#using-conditionals-in-the-submit-description-file
> https://htcondor.readthedocs.io/en/latest/misc-concepts/transforms.html
>
>
> [3]
> condor-9.0.6-1.el7.x86_64
> condor-boinc-7.16.16-1.el7.x86_64
> condor-classads-9.0.6-1.el7.x86_64
> condor-externals-9.0.6-1.el7.x86_64
> condor-procd-9.0.6-1.el7.x86_64
> htcondor-ce-5.1.1-1.el7.noarch
> htcondor-ce-apel-5.1.1-1.el7.noarch
> htcondor-ce-bdii-5.1.1-1.el7.noarch
> htcondor-ce-client-5.1.1-1.el7.noarch
> htcondor-ce-condor-5.1.1-1.el7.noarch
> htcondor-ce-view-5.1.1-1.el7.noarch
> python2-condor-9.0.6-1.el7.x86_64
> python3-condor-9.0.6-1.el7.x86_64
>
>
> _______________________________________________
> 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/