Skip to content

Runtime Parameterized Validators #1234

Answered by glados-verma
wtt901 asked this question in Q&A
Discussion options

You must be logged in to vote

Okay that's good. Then you might find it useful that Python decorators are also callables. So instead of doing a decorated phase:

@htf.measures(
    htf.Measurement('resistance')
    .with_units('ohm')
    .in_range(minimum=5, maximum=17)
)
def MyPhaseFunction(test_api):
  ...

you can instead define the phase function first, and convert it into a phase later:

def MyPhaseFunction(test_api, ...):
  """Define the function, don't put any htf decorators that you need to change at runtime"""

# Later, once you have the validator limits etc.
min_ohms = 5
max_ohms = 17  # Fixed in example; you got these dynamically at runtime instead.

my_measurement = htf.Measurement('resistance').with_units('o…

Replies: 6 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@glados-verma
Comment options

Answer selected by glados-verma
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants