Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

monitors decorator does not fully copy the specification of the monitored phase #1100

Open
glados-verma opened this issue May 11, 2023 · 0 comments

Comments

@glados-verma
Copy link
Collaborator

monitor in monitors.py does not copy the specification of the phase being monitored, leading to bugs like #1096 . What's happening in that specific bug is that, monitored_phase_func calls the monitored phase using the test state, thus bypassing the plug registration scheme. So, if the phase needs a plug that isn't registered by another phase, the plug lookup will fail with a KeyError.

Repro example:

import openhtf as htf


class NoOpPlug(htf.plugs.BasePlug):
  """Does nothing."""


def monitor_one(test, *args, **kwargs):
  del test  # Unused.
  return 1


@htf.monitors('f_measurement', monitor_one, poll_interval_ms=100)
@htf.plug(noop=NoOpPlug)
def buggy_monitoring(test, *args, **kwargs):
  del test


def main():
  test = htf.Test(buggy_monitoring)
  test.execute(test_start=lambda: 'MyDutId')


if __name__ == '__main__':
  main()

This particular issue can be fixed by copying over the plugs e.g. in def monitors:

own_plugs = {p.name: p.cls for p in phase_desc.plugs}
...
@plugs.plug(update_kwargs=False, **monitor_plugs, **own_plugs)

But it's not addressing the root of the problem as described earlier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant