pygeai 0.6.0b7__py3-none-any.whl → 0.6.0b11__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pygeai/_docs/source/conf.py +78 -6
- pygeai/_docs/source/content/api_reference/embeddings.rst +31 -1
- pygeai/_docs/source/content/api_reference/evaluation.rst +590 -0
- pygeai/_docs/source/content/api_reference/feedback.rst +237 -0
- pygeai/_docs/source/content/api_reference/files.rst +592 -0
- pygeai/_docs/source/content/api_reference/gam.rst +401 -0
- pygeai/_docs/source/content/api_reference/proxy.rst +318 -0
- pygeai/_docs/source/content/api_reference/secrets.rst +495 -0
- pygeai/_docs/source/content/api_reference/usage_limits.rst +390 -0
- pygeai/_docs/source/content/api_reference.rst +7 -0
- pygeai/_docs/source/content/debugger.rst +376 -83
- pygeai/_docs/source/content/migration.rst +528 -0
- pygeai/_docs/source/content/modules.rst +1 -1
- pygeai/_docs/source/pygeai.cli.rst +8 -0
- pygeai/_docs/source/pygeai.tests.cli.rst +16 -0
- pygeai/_docs/source/pygeai.tests.core.embeddings.rst +16 -0
- pygeai/_docs/source/pygeai.tests.snippets.chat.rst +40 -0
- pygeai/_docs/source/pygeai.tests.snippets.dbg.rst +45 -0
- pygeai/_docs/source/pygeai.tests.snippets.embeddings.rst +40 -0
- pygeai/_docs/source/pygeai.tests.snippets.evaluation.dataset.rst +197 -0
- pygeai/_docs/source/pygeai.tests.snippets.evaluation.plan.rst +133 -0
- pygeai/_docs/source/pygeai.tests.snippets.evaluation.result.rst +37 -0
- pygeai/_docs/source/pygeai.tests.snippets.evaluation.rst +10 -0
- pygeai/_docs/source/pygeai.tests.snippets.rst +1 -0
- pygeai/admin/clients.py +5 -0
- pygeai/assistant/clients.py +7 -0
- pygeai/assistant/data_analyst/clients.py +2 -0
- pygeai/assistant/rag/clients.py +11 -0
- pygeai/chat/clients.py +236 -25
- pygeai/chat/endpoints.py +3 -1
- pygeai/cli/commands/chat.py +322 -1
- pygeai/cli/commands/embeddings.py +56 -8
- pygeai/cli/commands/migrate.py +994 -434
- pygeai/cli/error_handler.py +116 -0
- pygeai/cli/geai.py +28 -10
- pygeai/cli/parsers.py +8 -2
- pygeai/core/base/clients.py +3 -1
- pygeai/core/common/exceptions.py +11 -10
- pygeai/core/embeddings/__init__.py +19 -0
- pygeai/core/embeddings/clients.py +17 -2
- pygeai/core/embeddings/mappers.py +16 -2
- pygeai/core/embeddings/responses.py +9 -2
- pygeai/core/feedback/clients.py +1 -0
- pygeai/core/files/clients.py +5 -7
- pygeai/core/files/managers.py +42 -0
- pygeai/core/llm/clients.py +4 -0
- pygeai/core/plugins/clients.py +1 -0
- pygeai/core/rerank/clients.py +1 -0
- pygeai/core/secrets/clients.py +6 -0
- pygeai/core/services/rest.py +1 -1
- pygeai/dbg/__init__.py +3 -0
- pygeai/dbg/debugger.py +565 -70
- pygeai/evaluation/clients.py +1 -1
- pygeai/evaluation/dataset/clients.py +45 -44
- pygeai/evaluation/plan/clients.py +27 -26
- pygeai/evaluation/result/clients.py +37 -5
- pygeai/gam/clients.py +4 -0
- pygeai/health/clients.py +1 -0
- pygeai/lab/agents/clients.py +8 -1
- pygeai/lab/models.py +3 -3
- pygeai/lab/processes/clients.py +21 -0
- pygeai/lab/strategies/clients.py +4 -0
- pygeai/lab/tools/clients.py +1 -0
- pygeai/migration/__init__.py +31 -0
- pygeai/migration/strategies.py +404 -155
- pygeai/migration/tools.py +170 -3
- pygeai/organization/clients.py +13 -0
- pygeai/organization/limits/clients.py +15 -0
- pygeai/proxy/clients.py +3 -1
- pygeai/tests/admin/test_clients.py +16 -11
- pygeai/tests/assistants/rag/test_clients.py +35 -23
- pygeai/tests/assistants/test_clients.py +22 -15
- pygeai/tests/auth/test_clients.py +14 -6
- pygeai/tests/chat/test_clients.py +211 -1
- pygeai/tests/cli/commands/test_embeddings.py +32 -9
- pygeai/tests/cli/commands/test_evaluation.py +7 -0
- pygeai/tests/cli/commands/test_migrate.py +112 -243
- pygeai/tests/cli/test_error_handler.py +225 -0
- pygeai/tests/cli/test_geai_driver.py +154 -0
- pygeai/tests/cli/test_parsers.py +5 -5
- pygeai/tests/core/embeddings/test_clients.py +144 -0
- pygeai/tests/core/embeddings/test_managers.py +171 -0
- pygeai/tests/core/embeddings/test_mappers.py +142 -0
- pygeai/tests/core/feedback/test_clients.py +2 -0
- pygeai/tests/core/files/test_clients.py +1 -0
- pygeai/tests/core/llm/test_clients.py +14 -9
- pygeai/tests/core/plugins/test_clients.py +5 -3
- pygeai/tests/core/rerank/test_clients.py +1 -0
- pygeai/tests/core/secrets/test_clients.py +19 -13
- pygeai/tests/dbg/test_debugger.py +453 -75
- pygeai/tests/evaluation/dataset/test_clients.py +3 -1
- pygeai/tests/evaluation/plan/test_clients.py +4 -2
- pygeai/tests/evaluation/result/test_clients.py +7 -5
- pygeai/tests/gam/test_clients.py +1 -1
- pygeai/tests/health/test_clients.py +1 -0
- pygeai/tests/lab/agents/test_clients.py +9 -0
- pygeai/tests/lab/processes/test_clients.py +36 -0
- pygeai/tests/lab/processes/test_mappers.py +3 -0
- pygeai/tests/lab/strategies/test_clients.py +14 -9
- pygeai/tests/migration/test_strategies.py +45 -218
- pygeai/tests/migration/test_tools.py +133 -9
- pygeai/tests/organization/limits/test_clients.py +17 -0
- pygeai/tests/organization/test_clients.py +22 -0
- pygeai/tests/proxy/test_clients.py +2 -0
- pygeai/tests/proxy/test_integration.py +1 -0
- pygeai/tests/snippets/chat/chat_completion_with_reasoning_effort.py +18 -0
- pygeai/tests/snippets/chat/get_response.py +15 -0
- pygeai/tests/snippets/chat/get_response_streaming.py +20 -0
- pygeai/tests/snippets/chat/get_response_with_files.py +16 -0
- pygeai/tests/snippets/chat/get_response_with_tools.py +36 -0
- pygeai/tests/snippets/dbg/__init__.py +0 -0
- pygeai/tests/snippets/dbg/basic_debugging.py +32 -0
- pygeai/tests/snippets/dbg/breakpoint_management.py +48 -0
- pygeai/tests/snippets/dbg/stack_navigation.py +45 -0
- pygeai/tests/snippets/dbg/stepping_example.py +40 -0
- pygeai/tests/snippets/embeddings/cache_example.py +31 -0
- pygeai/tests/snippets/embeddings/cohere_example.py +41 -0
- pygeai/tests/snippets/embeddings/openai_base64_example.py +27 -0
- pygeai/tests/snippets/embeddings/openai_example.py +30 -0
- pygeai/tests/snippets/embeddings/similarity_example.py +42 -0
- pygeai/tests/snippets/evaluation/dataset/__init__.py +0 -0
- pygeai/tests/snippets/evaluation/dataset/complete_workflow_example.py +195 -0
- pygeai/tests/snippets/evaluation/dataset/create_dataset.py +26 -0
- pygeai/tests/snippets/evaluation/dataset/create_dataset_from_file.py +11 -0
- pygeai/tests/snippets/evaluation/dataset/create_dataset_row.py +17 -0
- pygeai/tests/snippets/evaluation/dataset/create_expected_source.py +18 -0
- pygeai/tests/snippets/evaluation/dataset/create_filter_variable.py +19 -0
- pygeai/tests/snippets/evaluation/dataset/delete_dataset.py +9 -0
- pygeai/tests/snippets/evaluation/dataset/delete_dataset_row.py +10 -0
- pygeai/tests/snippets/evaluation/dataset/delete_expected_source.py +15 -0
- pygeai/tests/snippets/evaluation/dataset/delete_filter_variable.py +15 -0
- pygeai/tests/snippets/evaluation/dataset/get_dataset.py +9 -0
- pygeai/tests/snippets/evaluation/dataset/get_dataset_row.py +10 -0
- pygeai/tests/snippets/evaluation/dataset/get_expected_source.py +15 -0
- pygeai/tests/snippets/evaluation/dataset/get_filter_variable.py +15 -0
- pygeai/tests/snippets/evaluation/dataset/list_dataset_rows.py +9 -0
- pygeai/tests/snippets/evaluation/dataset/list_datasets.py +6 -0
- pygeai/tests/snippets/evaluation/dataset/list_expected_sources.py +10 -0
- pygeai/tests/snippets/evaluation/dataset/list_filter_variables.py +10 -0
- pygeai/tests/snippets/evaluation/dataset/update_dataset.py +15 -0
- pygeai/tests/snippets/evaluation/dataset/update_dataset_row.py +20 -0
- pygeai/tests/snippets/evaluation/dataset/update_expected_source.py +18 -0
- pygeai/tests/snippets/evaluation/dataset/update_filter_variable.py +19 -0
- pygeai/tests/snippets/evaluation/dataset/upload_dataset_rows_file.py +10 -0
- pygeai/tests/snippets/evaluation/plan/__init__.py +0 -0
- pygeai/tests/snippets/evaluation/plan/add_plan_system_metric.py +13 -0
- pygeai/tests/snippets/evaluation/plan/complete_workflow_example.py +136 -0
- pygeai/tests/snippets/evaluation/plan/create_evaluation_plan.py +24 -0
- pygeai/tests/snippets/evaluation/plan/create_rag_evaluation_plan.py +22 -0
- pygeai/tests/snippets/evaluation/plan/delete_evaluation_plan.py +9 -0
- pygeai/tests/snippets/evaluation/plan/delete_plan_system_metric.py +13 -0
- pygeai/tests/snippets/evaluation/plan/execute_evaluation_plan.py +11 -0
- pygeai/tests/snippets/evaluation/plan/get_evaluation_plan.py +9 -0
- pygeai/tests/snippets/evaluation/plan/get_plan_system_metric.py +13 -0
- pygeai/tests/snippets/evaluation/plan/get_system_metric.py +9 -0
- pygeai/tests/snippets/evaluation/plan/list_evaluation_plans.py +7 -0
- pygeai/tests/snippets/evaluation/plan/list_plan_system_metrics.py +9 -0
- pygeai/tests/snippets/evaluation/plan/list_system_metrics.py +7 -0
- pygeai/tests/snippets/evaluation/plan/update_evaluation_plan.py +22 -0
- pygeai/tests/snippets/evaluation/plan/update_plan_system_metric.py +14 -0
- pygeai/tests/snippets/evaluation/result/__init__.py +0 -0
- pygeai/tests/snippets/evaluation/result/complete_workflow_example.py +150 -0
- pygeai/tests/snippets/evaluation/result/get_evaluation_result.py +26 -0
- pygeai/tests/snippets/evaluation/result/list_evaluation_results.py +17 -0
- pygeai/tests/snippets/migrate/__init__.py +45 -0
- pygeai/tests/snippets/migrate/agent_migration.py +110 -0
- pygeai/tests/snippets/migrate/assistant_migration.py +64 -0
- pygeai/tests/snippets/migrate/orchestrator_examples.py +179 -0
- pygeai/tests/snippets/migrate/process_migration.py +64 -0
- pygeai/tests/snippets/migrate/project_migration.py +42 -0
- pygeai/tests/snippets/migrate/tool_migration.py +64 -0
- pygeai/tests/snippets/organization/create_project.py +2 -2
- {pygeai-0.6.0b7.dist-info → pygeai-0.6.0b11.dist-info}/METADATA +1 -1
- {pygeai-0.6.0b7.dist-info → pygeai-0.6.0b11.dist-info}/RECORD +178 -96
- {pygeai-0.6.0b7.dist-info → pygeai-0.6.0b11.dist-info}/WHEEL +0 -0
- {pygeai-0.6.0b7.dist-info → pygeai-0.6.0b11.dist-info}/entry_points.txt +0 -0
- {pygeai-0.6.0b7.dist-info → pygeai-0.6.0b11.dist-info}/licenses/LICENSE +0 -0
- {pygeai-0.6.0b7.dist-info → pygeai-0.6.0b11.dist-info}/top_level.txt +0 -0
|
@@ -4,9 +4,17 @@ PyGEAI Debugger
|
|
|
4
4
|
Overview
|
|
5
5
|
--------
|
|
6
6
|
|
|
7
|
-
``geai-dbg`` is a command-line debugger for the ``geai`` CLI tool, part of the ``pygeai`` package. It allows developers to pause execution at specified points (breakpoints) in the ``geai`` codebase, inspect local variables,
|
|
7
|
+
``geai-dbg`` is a command-line debugger for the ``geai`` CLI tool, part of the ``pygeai`` package. It allows developers to pause execution at specified points (breakpoints) in the ``geai`` codebase, inspect local variables, navigate the call stack, step through code execution, and control program flow interactively.
|
|
8
8
|
|
|
9
|
-
The debugger
|
|
9
|
+
The debugger provides features similar to Python's built-in ``pdb`` debugger, including:
|
|
10
|
+
|
|
11
|
+
- **Breakpoint management**: Set, list, enable/disable, and remove breakpoints
|
|
12
|
+
- **Stepping**: Step into, over, and out of function calls
|
|
13
|
+
- **Stack navigation**: Move up and down the call stack to inspect different frames
|
|
14
|
+
- **Variable inspection**: Print, pretty-print, and examine local/global variables
|
|
15
|
+
- **Source code display**: View source code around the current execution point
|
|
16
|
+
- **Performance optimization**: Only traces relevant modules to minimize overhead
|
|
17
|
+
- **Command history**: Uses readline for command history and editing
|
|
10
18
|
|
|
11
19
|
Installation and Setup
|
|
12
20
|
---------------------
|
|
@@ -22,6 +30,9 @@ No additional setup is required. The debugger script (``debugger.py``) is locate
|
|
|
22
30
|
Usage
|
|
23
31
|
-----
|
|
24
32
|
|
|
33
|
+
Basic Usage
|
|
34
|
+
~~~~~~~~~~~
|
|
35
|
+
|
|
25
36
|
To use ``geai-dbg``, run it with the same arguments you would pass to the ``geai`` CLI. For example:
|
|
26
37
|
|
|
27
38
|
.. code-block:: bash
|
|
@@ -32,50 +43,163 @@ This command runs the ``geai`` CLI with the arguments ``ail lrs`` under the debu
|
|
|
32
43
|
|
|
33
44
|
Upon hitting a breakpoint, the debugger displays:
|
|
34
45
|
|
|
35
|
-
- The location (module and function) where execution is paused
|
|
36
|
-
-
|
|
37
|
-
- An interactive prompt ``(geai-dbg)`` for entering commands
|
|
46
|
+
- The location (module and function) where execution is paused
|
|
47
|
+
- Source code context around the current line
|
|
48
|
+
- An interactive prompt ``(geai-dbg)`` for entering commands
|
|
38
49
|
|
|
39
|
-
|
|
50
|
+
Custom Target Functions
|
|
51
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
40
52
|
|
|
41
|
-
|
|
42
|
-
|
|
53
|
+
You can also debug custom Python functions using the ``Debugger`` class directly:
|
|
54
|
+
|
|
55
|
+
.. code-block:: python
|
|
56
|
+
|
|
57
|
+
from pygeai.dbg.debugger import Debugger
|
|
58
|
+
|
|
59
|
+
def my_function():
|
|
60
|
+
x = 10
|
|
61
|
+
y = 20
|
|
62
|
+
result = x + y
|
|
63
|
+
print(f"Result: {result}")
|
|
64
|
+
|
|
65
|
+
# Create debugger and set breakpoint
|
|
66
|
+
dbg = Debugger(target=my_function, module_filter="__main__")
|
|
67
|
+
dbg.add_breakpoint(module="__main__", function_name="my_function")
|
|
68
|
+
dbg.run()
|
|
69
|
+
|
|
70
|
+
Commands Reference
|
|
71
|
+
------------------
|
|
43
72
|
|
|
44
73
|
At the ``(geai-dbg)`` prompt, the following commands are available:
|
|
45
74
|
|
|
46
|
-
|
|
75
|
+
Flow Control
|
|
76
|
+
~~~~~~~~~~~~
|
|
77
|
+
|
|
78
|
+
**continue, c**
|
|
47
79
|
Resume execution until the next breakpoint is hit or the program completes.
|
|
48
80
|
|
|
49
|
-
|
|
50
|
-
|
|
81
|
+
**step, s**
|
|
82
|
+
Execute the current line and stop at the first possible occasion (either in a function that is called or on the next line in the current function).
|
|
83
|
+
|
|
84
|
+
**next, n**
|
|
85
|
+
Continue execution until the next line in the current function is reached or it returns (step over function calls).
|
|
86
|
+
|
|
87
|
+
**return, ret**
|
|
88
|
+
Continue execution until the current function returns.
|
|
51
89
|
|
|
52
|
-
run, r
|
|
90
|
+
**run, r**
|
|
53
91
|
Run the program to completion, disabling all breakpoints and skipping further pauses.
|
|
54
92
|
|
|
55
|
-
|
|
56
|
-
|
|
93
|
+
**quit, q, Ctrl+D**
|
|
94
|
+
Exit the debugger, terminating the program with a clean exit status (0).
|
|
95
|
+
|
|
96
|
+
Stack Navigation
|
|
97
|
+
~~~~~~~~~~~~~~~~
|
|
98
|
+
|
|
99
|
+
**where, w, bt, backtrace**
|
|
100
|
+
Display the stack trace, showing all frames from the current execution point to the top of the call stack.
|
|
101
|
+
|
|
102
|
+
**up, u**
|
|
103
|
+
Move up one level in the stack trace (to an older frame). This allows you to inspect the context of the caller.
|
|
104
|
+
|
|
105
|
+
**down, d**
|
|
106
|
+
Move down one level in the stack trace (to a newer frame).
|
|
107
|
+
|
|
108
|
+
Source Display
|
|
109
|
+
~~~~~~~~~~~~~~
|
|
110
|
+
|
|
111
|
+
**list, l [n]**
|
|
112
|
+
Show source code around the current line. Optional argument ``n`` specifies the number of lines of context (default: 10).
|
|
113
|
+
|
|
114
|
+
Variable Inspection
|
|
115
|
+
~~~~~~~~~~~~~~~~~~~
|
|
116
|
+
|
|
117
|
+
**print, p <expression>**
|
|
118
|
+
Evaluate and print the value of a Python expression in the current frame's context.
|
|
119
|
+
|
|
120
|
+
Example: ``p x + y``
|
|
121
|
+
|
|
122
|
+
**pp <expression>**
|
|
123
|
+
Pretty-print the value of a Python expression using ``pprint.pprint()``.
|
|
124
|
+
|
|
125
|
+
Example: ``pp locals()``
|
|
57
126
|
|
|
58
|
-
|
|
59
|
-
|
|
127
|
+
**locals, loc**
|
|
128
|
+
Display all local variables in the current frame.
|
|
60
129
|
|
|
61
|
-
|
|
62
|
-
|
|
130
|
+
**globals, glob**
|
|
131
|
+
Display all global variables in the current frame (excluding built-ins).
|
|
63
132
|
|
|
64
|
-
|
|
133
|
+
**args, a**
|
|
134
|
+
Display the arguments of the current function.
|
|
135
|
+
|
|
136
|
+
Breakpoint Management
|
|
137
|
+
~~~~~~~~~~~~~~~~~~~~~
|
|
138
|
+
|
|
139
|
+
**break, b**
|
|
140
|
+
List all breakpoints with their status, hit counts, and conditions.
|
|
141
|
+
|
|
142
|
+
**b <function>**
|
|
143
|
+
Set a breakpoint on any function with the given name.
|
|
144
|
+
|
|
145
|
+
Example: ``b main``
|
|
146
|
+
|
|
147
|
+
**b <module>:<function>**
|
|
148
|
+
Set a breakpoint on a specific function in a specific module.
|
|
149
|
+
|
|
150
|
+
Example: ``b pygeai.cli.geai:main``
|
|
151
|
+
|
|
152
|
+
**clear, cl <breakpoint>**
|
|
153
|
+
Remove a breakpoint. Use the same syntax as setting a breakpoint.
|
|
154
|
+
|
|
155
|
+
Example: ``cl main`` or ``cl pygeai.cli.geai:main``
|
|
156
|
+
|
|
157
|
+
**clearall, cla**
|
|
158
|
+
Remove all breakpoints.
|
|
159
|
+
|
|
160
|
+
**enable, en <breakpoint>**
|
|
161
|
+
Enable a disabled breakpoint.
|
|
162
|
+
|
|
163
|
+
Example: ``en main``
|
|
164
|
+
|
|
165
|
+
**disable, dis <breakpoint>**
|
|
166
|
+
Disable a breakpoint without removing it.
|
|
167
|
+
|
|
168
|
+
Example: ``dis main``
|
|
169
|
+
|
|
170
|
+
Legacy Commands
|
|
171
|
+
~~~~~~~~~~~~~~~
|
|
172
|
+
|
|
173
|
+
These commands are maintained for backward compatibility:
|
|
174
|
+
|
|
175
|
+
**breakpoint-module, bm**
|
|
176
|
+
Add a breakpoint for a specific module (interactive prompt).
|
|
177
|
+
|
|
178
|
+
**breakpoint-function, bf**
|
|
179
|
+
Add a breakpoint for a specific function (interactive prompt).
|
|
180
|
+
|
|
181
|
+
**list-modules, lm**
|
|
182
|
+
List all loaded modules starting with the module filter (default: ``pygeai``).
|
|
183
|
+
|
|
184
|
+
Other Commands
|
|
185
|
+
~~~~~~~~~~~~~~
|
|
186
|
+
|
|
187
|
+
**help, h, ?**
|
|
65
188
|
Display a list of available commands and their descriptions.
|
|
66
189
|
|
|
67
|
-
|
|
68
|
-
Execute arbitrary Python code in the current context. For example, ``print(sys.argv)
|
|
190
|
+
**<Python code>**
|
|
191
|
+
Execute arbitrary Python code in the current frame's context. For example, ``x = 42`` or ``print(sys.argv)``. Errors are caught and logged without crashing the debugger.
|
|
69
192
|
|
|
70
|
-
Ctrl+C
|
|
193
|
+
**Ctrl+C**
|
|
71
194
|
Interrupt the current command input and resume execution, equivalent to ``continue``.
|
|
72
195
|
|
|
73
196
|
Examples
|
|
74
197
|
--------
|
|
75
198
|
|
|
76
|
-
|
|
199
|
+
Example 1: Basic Debugging
|
|
200
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
77
201
|
|
|
78
|
-
|
|
202
|
+
Debug the ``geai ail lrs`` command:
|
|
79
203
|
|
|
80
204
|
.. code-block:: bash
|
|
81
205
|
|
|
@@ -85,84 +209,213 @@ Output:
|
|
|
85
209
|
|
|
86
210
|
.. code-block:: text
|
|
87
211
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
212
|
+
2026-01-07 15:04:57,263 - geai.dbg - INFO - GEAI debugger started.
|
|
213
|
+
2026-01-07 15:04:57,264 - geai.dbg - INFO - Breakpoint added: pygeai.cli.geai:main (enabled, hits: 0)
|
|
214
|
+
2026-01-07 15:04:57,264 - geai.dbg - INFO - Setting trace and running target
|
|
215
|
+
2026-01-07 15:04:57,264 - geai.dbg - INFO - Breakpoint hit at pygeai.cli.geai.main (hit #1)
|
|
216
|
+
|
|
217
|
+
============================================================
|
|
218
|
+
Paused at pygeai.cli.geai.main (line 42)
|
|
219
|
+
|
|
220
|
+
Source (/path/to/pygeai/cli/geai.py):
|
|
221
|
+
39
|
|
222
|
+
40 class CLIDriver:
|
|
223
|
+
41 def main(self):
|
|
224
|
+
-> 42 parser = ArgumentParser()
|
|
225
|
+
43 args = parser.parse_args()
|
|
226
|
+
44 return self.execute(args)
|
|
227
|
+
45
|
|
228
|
+
============================================================
|
|
229
|
+
Type 'h' for help, 'c' to continue
|
|
97
230
|
(geai-dbg)
|
|
98
231
|
|
|
99
|
-
|
|
232
|
+
Example 2: Stepping Through Code
|
|
233
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
234
|
+
|
|
235
|
+
At a breakpoint, step through code execution:
|
|
100
236
|
|
|
101
237
|
.. code-block:: text
|
|
102
238
|
|
|
103
|
-
(geai-dbg)
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
<Python code>: Execute arbitrary Python code in the current context
|
|
239
|
+
(geai-dbg) s
|
|
240
|
+
# Steps into the next function call
|
|
241
|
+
|
|
242
|
+
(geai-dbg) n
|
|
243
|
+
# Steps over function calls, staying in the current function
|
|
244
|
+
|
|
245
|
+
(geai-dbg) ret
|
|
246
|
+
# Continues until the current function returns
|
|
112
247
|
|
|
113
|
-
|
|
248
|
+
Example 3: Inspecting Variables
|
|
249
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
250
|
+
|
|
251
|
+
Examine variables at a breakpoint:
|
|
114
252
|
|
|
115
253
|
.. code-block:: text
|
|
116
254
|
|
|
117
|
-
(geai-dbg)
|
|
118
|
-
|
|
119
|
-
|
|
255
|
+
(geai-dbg) p x
|
|
256
|
+
42
|
|
257
|
+
|
|
258
|
+
(geai-dbg) pp locals()
|
|
259
|
+
{'x': 42,
|
|
260
|
+
'y': 20,
|
|
261
|
+
'result': 62}
|
|
262
|
+
|
|
263
|
+
(geai-dbg) args
|
|
264
|
+
Function arguments:
|
|
265
|
+
self = <pygeai.cli.geai.CLIDriver object at 0x...>
|
|
266
|
+
args = None
|
|
267
|
+
|
|
268
|
+
Example 4: Stack Navigation
|
|
269
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
120
270
|
|
|
121
|
-
|
|
271
|
+
Navigate the call stack:
|
|
122
272
|
|
|
123
273
|
.. code-block:: text
|
|
124
274
|
|
|
125
|
-
(geai-dbg)
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
275
|
+
(geai-dbg) where
|
|
276
|
+
Stack trace (most recent call last):
|
|
277
|
+
#0 __main__.level_3 at /path/to/script.py:15
|
|
278
|
+
> #1 __main__.level_2 at /path/to/script.py:10
|
|
279
|
+
#2 __main__.level_1 at /path/to/script.py:5
|
|
280
|
+
|
|
281
|
+
(geai-dbg) up
|
|
282
|
+
Frame #0: __main__.level_2
|
|
283
|
+
|
|
284
|
+
(geai-dbg) locals
|
|
285
|
+
Local variables:
|
|
286
|
+
{'value': 'level 2'}
|
|
287
|
+
|
|
288
|
+
(geai-dbg) down
|
|
289
|
+
Frame #1: __main__.level_3
|
|
290
|
+
|
|
291
|
+
Example 5: Breakpoint Management
|
|
292
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
293
|
+
|
|
294
|
+
Manage breakpoints during debugging:
|
|
130
295
|
|
|
131
|
-
|
|
132
|
-
Enter commands to execute in the current context (type 'continue' to resume, 'quit' to exit, 'help' to display available commands):
|
|
133
|
-
(geai-dbg)
|
|
296
|
+
.. code-block:: text
|
|
134
297
|
|
|
135
|
-
|
|
298
|
+
(geai-dbg) b
|
|
299
|
+
Breakpoints:
|
|
300
|
+
1. pygeai.cli.geai:main (enabled, hits: 1)
|
|
301
|
+
|
|
302
|
+
(geai-dbg) b process_data
|
|
303
|
+
Breakpoint added: *:process_data (enabled, hits: 0)
|
|
304
|
+
|
|
305
|
+
(geai-dbg) b pygeai.core:helper_function
|
|
306
|
+
Breakpoint added: pygeai.core:helper_function (enabled, hits: 0)
|
|
307
|
+
|
|
308
|
+
(geai-dbg) dis process_data
|
|
309
|
+
Breakpoint disabled: *:process_data (disabled, hits: 0)
|
|
310
|
+
|
|
311
|
+
(geai-dbg) cl pygeai.core:helper_function
|
|
312
|
+
Breakpoint removed: pygeai.core:helper_function
|
|
313
|
+
|
|
314
|
+
Example 6: Viewing Source Code
|
|
315
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
316
|
+
|
|
317
|
+
Display source code around the current line:
|
|
136
318
|
|
|
137
319
|
.. code-block:: text
|
|
138
320
|
|
|
139
|
-
(geai-dbg)
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
321
|
+
(geai-dbg) list 5
|
|
322
|
+
Source (/path/to/file.py):
|
|
323
|
+
10 def process_data(data):
|
|
324
|
+
11 result = []
|
|
325
|
+
12 for item in data:
|
|
326
|
+
-> 13 processed = helper_function(item)
|
|
327
|
+
14 result.append(processed)
|
|
328
|
+
15 return result
|
|
145
329
|
|
|
146
|
-
|
|
330
|
+
Advanced Features
|
|
331
|
+
-----------------
|
|
147
332
|
|
|
148
|
-
|
|
333
|
+
Module Filtering
|
|
334
|
+
~~~~~~~~~~~~~~~~
|
|
149
335
|
|
|
150
|
-
|
|
336
|
+
The debugger includes a performance optimization that only traces modules matching a specified prefix (default: ``pygeai``). This significantly reduces overhead compared to tracing all Python code.
|
|
151
337
|
|
|
152
|
-
|
|
153
|
-
2025-05-12 15:05:21,300 - geai - INFO - Executing interactive command: print(sys.argv)
|
|
154
|
-
['/path/to/venv/bin/geai-dbg', 'ail', 'lrs']
|
|
338
|
+
When creating a custom debugger, you can specify the module filter:
|
|
155
339
|
|
|
156
|
-
|
|
340
|
+
.. code-block:: python
|
|
157
341
|
|
|
158
|
-
|
|
342
|
+
dbg = Debugger(target=my_function, module_filter="my_package")
|
|
159
343
|
|
|
160
|
-
|
|
344
|
+
This will only trace modules starting with ``my_package``, ignoring standard library and third-party code.
|
|
345
|
+
|
|
346
|
+
Conditional Breakpoints
|
|
347
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
348
|
+
|
|
349
|
+
Breakpoints can include conditions that must be met for the breakpoint to trigger:
|
|
350
|
+
|
|
351
|
+
.. code-block:: python
|
|
352
|
+
|
|
353
|
+
dbg = Debugger(target=my_function)
|
|
354
|
+
dbg.add_breakpoint(
|
|
355
|
+
module="my_module",
|
|
356
|
+
function_name="process_item",
|
|
357
|
+
condition="item > 100"
|
|
358
|
+
)
|
|
359
|
+
|
|
360
|
+
The breakpoint will only trigger when ``item > 100`` evaluates to ``True`` in the function's context.
|
|
361
|
+
|
|
362
|
+
Command History
|
|
363
|
+
~~~~~~~~~~~~~~~
|
|
364
|
+
|
|
365
|
+
The debugger uses Python's ``readline`` module to provide command history and line editing. You can use:
|
|
366
|
+
|
|
367
|
+
- **Up/Down arrows**: Navigate through command history
|
|
368
|
+
- **Ctrl+R**: Search command history
|
|
369
|
+
- **Tab**: (if configured) Auto-completion
|
|
370
|
+
|
|
371
|
+
Command history is saved to ``~/.geai_dbg_history`` and persists across debugging sessions.
|
|
372
|
+
|
|
373
|
+
Programmatic Usage
|
|
374
|
+
~~~~~~~~~~~~~~~~~~
|
|
375
|
+
|
|
376
|
+
You can use the ``Debugger`` class programmatically in your own code:
|
|
377
|
+
|
|
378
|
+
.. code-block:: python
|
|
379
|
+
|
|
380
|
+
from pygeai.dbg.debugger import Debugger, Breakpoint
|
|
381
|
+
|
|
382
|
+
def my_target():
|
|
383
|
+
# Your code here
|
|
384
|
+
pass
|
|
385
|
+
|
|
386
|
+
# Create debugger
|
|
387
|
+
dbg = Debugger(target=my_target, module_filter="my_package")
|
|
388
|
+
|
|
389
|
+
# Add breakpoints
|
|
390
|
+
dbg.add_breakpoint(module="my_package.module", function_name="my_function")
|
|
391
|
+
dbg.add_breakpoint(function_name="helper", condition="x > 10")
|
|
392
|
+
|
|
393
|
+
# List breakpoints
|
|
394
|
+
for bp in dbg.list_breakpoints():
|
|
395
|
+
print(f"Breakpoint: {bp}")
|
|
396
|
+
|
|
397
|
+
# Run under debugger
|
|
398
|
+
dbg.run()
|
|
399
|
+
|
|
400
|
+
# Reset state for reuse
|
|
401
|
+
dbg.reset()
|
|
402
|
+
|
|
403
|
+
Tips and Best Practices
|
|
404
|
+
-----------------------
|
|
405
|
+
|
|
406
|
+
1. **Start with targeted breakpoints**: Set specific breakpoints on the functions you want to debug rather than using wildcards.
|
|
161
407
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
408
|
+
2. **Use step wisely**: The ``step`` command can be slow if it steps into many library functions. Use ``next`` to stay at the same level.
|
|
409
|
+
|
|
410
|
+
3. **Inspect the stack**: Use ``where`` to understand the call chain, especially in complex codebases.
|
|
411
|
+
|
|
412
|
+
4. **Pretty-print complex data**: Use ``pp`` instead of ``p`` for dictionaries, lists, and other complex structures.
|
|
413
|
+
|
|
414
|
+
5. **Disable instead of removing**: Use ``disable`` to temporarily turn off breakpoints you might need again, rather than removing them.
|
|
415
|
+
|
|
416
|
+
6. **Use module filtering**: When debugging custom code, set ``module_filter`` to your package name to avoid tracing unrelated code.
|
|
417
|
+
|
|
418
|
+
7. **Conditional breakpoints**: Use conditions to break only when specific criteria are met, reducing manual stepping.
|
|
166
419
|
|
|
167
420
|
Notes
|
|
168
421
|
-----
|
|
@@ -172,17 +425,57 @@ Notes
|
|
|
172
425
|
- Pressing ``Ctrl+C`` resumes execution, equivalent to the ``continue`` command.
|
|
173
426
|
|
|
174
427
|
- **Python Code Execution**:
|
|
175
|
-
- Arbitrary Python code executed at the prompt runs in the context of the
|
|
428
|
+
- Arbitrary Python code executed at the prompt runs in the context of the current frame, with access to local and global variables. Use with caution, as it can modify program state.
|
|
176
429
|
|
|
177
|
-
- **
|
|
178
|
-
-
|
|
430
|
+
- **Performance**:
|
|
431
|
+
- The debugger uses ``sys.settrace`` which has performance overhead. The module filter helps minimize this, but expect slower execution than running without the debugger.
|
|
432
|
+
|
|
433
|
+
- **Breakpoint Persistence**:
|
|
434
|
+
- Breakpoints persist across ``continue`` commands but are cleared when the program exits. They are not saved to disk.
|
|
179
435
|
|
|
180
436
|
- **Logging**:
|
|
181
|
-
- The debugger logs to stdout with timestamps, including breakpoint hits,
|
|
437
|
+
- The debugger logs to stdout with timestamps, including breakpoint hits, state changes, and errors. The log level is set to DEBUG by default.
|
|
438
|
+
|
|
439
|
+
- **Frame Context**:
|
|
440
|
+
- When you move up/down the stack with ``up``/``down``, the current frame changes, affecting what ``locals``, ``globals``, and expression evaluation see.
|
|
441
|
+
|
|
442
|
+
Code Examples
|
|
443
|
+
-------------
|
|
444
|
+
|
|
445
|
+
See the ``pygeai/tests/snippets/dbg/`` directory for complete working examples:
|
|
446
|
+
|
|
447
|
+
- ``basic_debugging.py`` - Simple debugging with variable inspection
|
|
448
|
+
- ``stepping_example.py`` - Demonstrates step, next, and return commands
|
|
449
|
+
- ``stack_navigation.py`` - Shows stack traversal with up/down
|
|
450
|
+
- ``breakpoint_management.py`` - Examples of managing breakpoints
|
|
451
|
+
|
|
452
|
+
Run these examples with:
|
|
453
|
+
|
|
454
|
+
.. code-block:: bash
|
|
455
|
+
|
|
456
|
+
python -m pygeai.tests.snippets.dbg.basic_debugging
|
|
457
|
+
|
|
458
|
+
Troubleshooting
|
|
459
|
+
---------------
|
|
460
|
+
|
|
461
|
+
**Debugger is too slow**
|
|
462
|
+
Adjust the ``module_filter`` to trace only the modules you care about. The default filter is ``"pygeai"``.
|
|
463
|
+
|
|
464
|
+
**Breakpoint not hitting**
|
|
465
|
+
- Check that the module and function names match exactly (use ``lm`` to list loaded modules)
|
|
466
|
+
- Verify the breakpoint is enabled (use ``b`` to list breakpoints)
|
|
467
|
+
- Check if a condition is preventing the breakpoint from triggering
|
|
468
|
+
|
|
469
|
+
**Can't see local variables**
|
|
470
|
+
Make sure you're in the correct frame. Use ``where`` to see the stack and ``up``/``down`` to navigate.
|
|
471
|
+
|
|
472
|
+
**Source code not displaying**
|
|
473
|
+
The source file might not be accessible or the code might be in a compiled module. The debugger needs access to the ``.py`` source files.
|
|
182
474
|
|
|
183
|
-
For issues or feature requests, contact the ``pygeai`` development team.
|
|
475
|
+
For issues or feature requests, contact the ``pygeai`` development team or file an issue on the project's GitHub repository.
|
|
184
476
|
|
|
185
477
|
.. seealso::
|
|
186
478
|
|
|
187
|
-
- ``geai`` CLI documentation for details on the underlying command-line tool
|
|
188
|
-
- Python's ``sys.settrace`` documentation for technical details on the debugging mechanism
|
|
479
|
+
- ``geai`` CLI documentation for details on the underlying command-line tool
|
|
480
|
+
- Python's ``sys.settrace`` documentation for technical details on the debugging mechanism
|
|
481
|
+
- Python's ``pdb`` module for comparison with the standard Python debugger
|