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

Re: [HTCondor-users] Python and Requirements in a ClassAd



Thanks, Brian!

I figured out a solution just a few minutes before your response, but didn't know about the classad.quote().   I'll be sure to use that.

Steve

On May 13, 2014, at 5:18 PM, Brian Bockelman wrote:

> Hi Steve,
> 
> You are giving the ad a string object which becomes a string in the ad; what you want is an expression object which becomes an expression in the ad.  Try:
> 
> ad['Requirements'] = classad.ExprTree("TARGET.Machine =?= %s" % classad.quote("foo"))
> 
> Note that you want to use "classad.quote" instead of feeding an unsanitized string.  For example, what happens if the machine name includes a "?  In that case, using the quote function, you get:
> 
>>>> import classad
>>>> ad = classad.ClassAd()
>>>> ad['Requirements'] = classad.ExprTree("TARGET.Machine =?= %s" % classad.quote('f"oo'))
>>>> ad
> [ Requirements = TARGET.Machine is "f\"oo" ]
> 
> Hope this helps,
> 
> Brian
> 
> On May 13, 2014, at 5:01 PM, Stephen Pietrowicz <srp@xxxxxxxxxxxx> wrote:
> 
>> Hi,
>> 
>> I'd like to use the Python binding to submit a job. I've successfully submitted jobs while altering the class ad before submitting, and that works. works.
>> 
>> Now I'm trying to add Requirements to the class ad and ran into a problem.
>> 
>> A line like this in code:
>> 
>>           ad["Requirements"] = 'TARGET.Machine == "%s"' % machine
>> 
>> The Requirements expression for your job is:
>> 
>>   "TARGET.Machine == \"somemachine.ncsa.uiuc.edu\"" && TARGET.OPSYS == "LINUX" &&
>>   TARGET.ARCH == "X86_64" &&
>>   TARGET.FileSystemDomain == MY.FileSystemDomain &&
>>   TARGET.Disk >= RequestDisk && TARGET.Memory >= RequestMemory
>> 
>> Note the extra set of quotes around the machine expression.
>> 
>> What's the right syntax for adding this?  I'd also like to add the slot number, but I simplified the problem for this email.  I think I'm missing something pretty basic here.
>> 
>> Any help would be appreciated.
>> 
>> Steve
>> _______________________________________________
>> 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/
> 
> 
> _______________________________________________
> 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/
>