pcdshub / nabs

Not a Beamline Scientist
https://pcdshub.github.io/nabs
Other
3 stars 7 forks source link

WIP/ENH: Plan validation framework, extra checks #57

Closed tangkong closed 2 years ago

tangkong commented 2 years ago

Description

Adds a high level validate_plan function that runs a plan through multiple checks.
Adds check for proper plan construction (open_run/close_run matching, proper run_key tags) Adds check for stray calls, pulling from a pre-defined list of forbidden function calls.

Motivation and Context

Plan verification has always been on our radar, but hasn't been fully fleshed out. One could see this being useful to scientists building their own plans as a quick check before running them on the beamline. With the more recently developed RunWrapper functionality, one could see these checks being run before a plan is added to the hutch-python namespace and made available for generic use.

All of these plans attempt to simply examine messages, and as such avoid actually taking any actions. This does not, however, prevent a user from directly moving a motor within a plan via .put() or similar methods.

check_stray_calls attempts to remedy this by temporarily monkeypatching sys.modules. This may not be the best way to go about it, but it seemed more viable than:

How Has This Been Tested?

Test suite has been started.
interactively, for non-simulated motors

Still needs further testing with live PV's, and additional "forbidden methods"

Where Has This Been Documented?

Some docstrings, but mostly this PR

Pre-merge checklist

tangkong commented 2 years ago

I messed up the commit history, creating new PR based on current master