Add a function to classad that can query the attribute references of an expression

Description

It is common when writing a SUBMIT_TRANSFORM that adds clauses to a job's Requirements expression, to want to first check to see if the Requirements expression already has a constraint of that sort. For instance, if the requirements expression has OpSysAndVer == "Centos8", then Adding OpSysMajorVer == 7 will cause the job to not match anywhere.

We will add a new function to Classads that can return the list of external references for an expression, and can optional return a boolean if one of those external references matches a pattern.

The function will tentatively be called unresolved it will have two forms, The single argument form will return the list of external references of an expression as a comma separated string. The two argument form will return True if one of the external references matches a pattern and False if none of them do.

For example, if the job has the following requirements expression

Then the unresolved function can be used thus

The two argument form is the equivalent of

Activity

Show:
Todd L Miller
January 11, 2021, 11:09 PM

Code Review

The implementation looks solid.

  • It may be helpful in the ClassAd documentation to mention the assumption that OpSys is not defined in the Requirements expression’s ad.

Naming the function unresolved and then having it unconditionally return external references makes sense for its intended use-case, but really tripped me up reading the ClassAd documentation before the body of the ticket. Unfortunately, I can’t come up with anything better.

  • The documentation doesn’t mention the use-case from the body of the ticket, which seems like it might be helpful.

  • The version history item from the stable series hasn’t been merged to master yet. It also seems a little weird to refer to a new feature “from” the dev series that isn’t mentioned in the dev series' release notes. Maybe mention the use case there? (“Added a new a ClassAd function to help write submit transforms. You can now use unresolved() to check for existing constraints on a particular attribute (or attribute regex).”)

Time remaining

14h 15m

Assignee

John (TJ) Knoeller