def cleanup_global_controls(): """ Unload and cleanup global controls """ controls = global_controls.get() global_controls.set([]) for control in controls: name = control['name'] logger.debug("Cleaning up global control '{}'".format(name)) provider = control.get("provider") if provider and provider["type"] == "python": cleanup_control(control)
def cleanup_global_controls(): """ Unload and cleanup global controls """ controls = get_global_controls() reset_global_controls() for control in controls: name = control['name'] logger.debug("Cleaning up global control '{}'".format(name)) provider = control.get("provider") if provider and provider["type"] == "python": try: cleanup_control(control) except Exception: logger.debug( "Control cleanup '{}' failed".format(control['name']), exc_info=True)
def cleanup_controls(experiment: Experiment): """ Cleanup all declared controls in the experiment. On Python controls, this means calling the `cleanup_control` function of the exposed module. Controls are cleaned up once only when they are declared many times in the experiment with the same name. """ logger.debug("Cleaning up controls") controls = get_controls(experiment) seen = [] for control in controls: name = control.get("name") if not name or name in seen: continue seen.append(name) logger.debug("Cleaning up control '{}'".format(name)) provider = control.get("provider") if provider and provider["type"] == "python": cleanup_control(control)