Unfortunately you cannot use complex conditionals in if statements, you have to force them to evaluate to a boolean first
so you can do this
EVALMACRO QUEUE_CONDITION (JobCategory == "medium") || (JobCategory == "long")
if $(QUEUE_CONDITION)
Also to protect against the JobCategory attribute not being a string, you should use ?: to force the result to be boolean
EVALMACRO QUEUE_CONDITION (JobCategory == "medium") || (JobCategory == "long") ?: false
It is better to use $INT() rather than $EVAL() because coerces the result to an integer, which behaves like a boolean, while $EVAL does not.
-tj
From: HTCondor-users <htcondor-users-bounces@xxxxxxxxxxx> on behalf of Jeff Templon <templon@xxxxxxxxx>
Sent: Friday, February 7, 2025 2:42 AM To: HTCondor-Users Mail List <htcondor-users@xxxxxxxxxxx> Subject: [HTCondor-users] Even more job transform questions My rule (it’s under construction, hence all the duplication - I’m trying to figure out what is going on):
if !$(IsClusterAd)
EVALMACRO CLCoreEquiv max({ MY.RequestCpus, int(1 + MY.RequestMemory / 4097) })
EVALSET CLUserStr join(":", Owner, $(CLCoreEquiv))
QUEUE_CONDITION = (JobCategory == "medium") || (JobCategory == "long")
if $(QUEUE_CONDITION)
[ … ]
Whereupon the “nice” debugging tool says:
Invalid rules file clim.rule : $(QUEUE_CONDITION) is not a valid if condition because complex conditionals are not supported
When I change that the “if $EVAL(QUEUE_CONDITION)”,
Invalid rules file clim.rule : $EVAL(QUEUE_CONDITION) is not a valid if condition because _expression_ is not a conditional
Help appreciated.
JT
|