{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Standalone Debugger Example\n\nThis example demonstrates how to use BugDoc's algorithms in standalone mode\nwithout requiring ZMQ or an external worker process.\n\nIn standalone mode, you pass a Python function directly to the algorithm\nthat takes a parameter dictionary and returns a result.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from bugdoc.algos.stacked_shortcut_standalone import StackedShortcutStandalone\n\n\n# Example 1: Simple pipeline function\ndef my_pipeline(params):\n \"\"\"\n A simple pipeline function that takes parameter values and returns a boolean result.\n \n Parameters\n ----------\n params: dict\n Dictionary with parameter names as keys and their values.\n \n Returns\n -------\n bool\n True if the pipeline execution was successful, False otherwise.\n \"\"\"\n # Extract parameters\n mode = params.get('mode', 'default')\n value = params.get('value', 0)\n threshold = params.get('threshold', 0.5)\n \n # Run some logic\n result = value > threshold if mode == 'compare' else value > 0\n \n print(f\"Pipeline executed with params: {params}, result: {result}\")\n return result\n\n\n# Example 2: Using with the StackedShortcut algorithm in standalone mode\ndef main():\n # Define the parameter space\n parameter_space = {\n 'mode': ['compare', 'default', 'other'],\n 'value': [0.1, 0.5, 0.9],\n 'threshold': [0.3, 0.7]\n }\n \n # Create the debugger in standalone mode by passing the function\n debugger = StackedShortcutStandalone(max_iter=50, function=my_pipeline)\n \n # Run the debugger with the entry point (not used in standalone mode but required by API)\n result = debugger.run('pipeline_function', parameter_space)\n \n print(f\"\\nDebugger completed. Results:\\n{result}\")\n\n\nif __name__ == '__main__':\n main()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.20" } }, "nbformat": 4, "nbformat_minor": 0 }