ao-dev 0.0.3__tar.gz
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.
- ao_dev-0.0.3/PKG-INFO +41 -0
- ao_dev-0.0.3/README.md +87 -0
- ao_dev-0.0.3/ao_dev.egg-info/PKG-INFO +41 -0
- ao_dev-0.0.3/ao_dev.egg-info/SOURCES.txt +50 -0
- ao_dev-0.0.3/ao_dev.egg-info/dependency_links.txt +1 -0
- ao_dev-0.0.3/ao_dev.egg-info/entry_points.txt +6 -0
- ao_dev-0.0.3/ao_dev.egg-info/requires.txt +36 -0
- ao_dev-0.0.3/ao_dev.egg-info/top_level.txt +1 -0
- ao_dev-0.0.3/docs/PKG_README.md +1 -0
- ao_dev-0.0.3/pyproject.toml +83 -0
- ao_dev-0.0.3/setup.cfg +4 -0
- ao_dev-0.0.3/src/__init__.py +3 -0
- ao_dev-0.0.3/src/cli/__init__.py +0 -0
- ao_dev-0.0.3/src/cli/ao_config.py +71 -0
- ao_dev-0.0.3/src/cli/ao_record.py +92 -0
- ao_dev-0.0.3/src/cli/ao_server.py +230 -0
- ao_dev-0.0.3/src/common/__init__.py +0 -0
- ao_dev-0.0.3/src/common/config.py +361 -0
- ao_dev-0.0.3/src/common/constants.py +215 -0
- ao_dev-0.0.3/src/common/logger.py +56 -0
- ao_dev-0.0.3/src/common/utils.py +511 -0
- ao_dev-0.0.3/src/runner/__init__.py +0 -0
- ao_dev-0.0.3/src/runner/agent_runner.py +574 -0
- ao_dev-0.0.3/src/runner/ast_rewrite_hook.py +185 -0
- ao_dev-0.0.3/src/runner/context_manager.py +125 -0
- ao_dev-0.0.3/src/runner/monkey_patching/__init__.py +0 -0
- ao_dev-0.0.3/src/runner/monkey_patching/api_parser.py +279 -0
- ao_dev-0.0.3/src/runner/monkey_patching/api_parsers/__init__.py +0 -0
- ao_dev-0.0.3/src/runner/monkey_patching/api_parsers/genai_api_parser.py +89 -0
- ao_dev-0.0.3/src/runner/monkey_patching/api_parsers/httpx_api_parser.py +75 -0
- ao_dev-0.0.3/src/runner/monkey_patching/api_parsers/mcp_api_parser.py +52 -0
- ao_dev-0.0.3/src/runner/monkey_patching/api_parsers/requests_api_parser.py +64 -0
- ao_dev-0.0.3/src/runner/monkey_patching/apply_monkey_patches.py +56 -0
- ao_dev-0.0.3/src/runner/monkey_patching/patches/__init__.py +0 -0
- ao_dev-0.0.3/src/runner/monkey_patching/patches/file_patches.py +164 -0
- ao_dev-0.0.3/src/runner/monkey_patching/patches/genai_patch.py +74 -0
- ao_dev-0.0.3/src/runner/monkey_patching/patches/httpx_patch.py +117 -0
- ao_dev-0.0.3/src/runner/monkey_patching/patches/mcp_patches.py +76 -0
- ao_dev-0.0.3/src/runner/monkey_patching/patches/randomness_patch.py +52 -0
- ao_dev-0.0.3/src/runner/monkey_patching/patches/requests_patch.py +64 -0
- ao_dev-0.0.3/src/runner/monkey_patching/patching_utils.py +140 -0
- ao_dev-0.0.3/src/runner/taint_dict.py +72 -0
- ao_dev-0.0.3/src/server/__init__.py +0 -0
- ao_dev-0.0.3/src/server/ast_helpers.py +521 -0
- ao_dev-0.0.3/src/server/ast_transformer.py +586 -0
- ao_dev-0.0.3/src/server/auth_app.py +181 -0
- ao_dev-0.0.3/src/server/database_backends/__init__.py +0 -0
- ao_dev-0.0.3/src/server/database_backends/postgres.py +690 -0
- ao_dev-0.0.3/src/server/database_backends/sqlite.py +501 -0
- ao_dev-0.0.3/src/server/database_manager.py +611 -0
- ao_dev-0.0.3/src/server/file_watcher.py +516 -0
- ao_dev-0.0.3/src/server/main_server.py +1014 -0
ao_dev-0.0.3/PKG-INFO
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ao-dev
|
|
3
|
+
Version: 0.0.3
|
|
4
|
+
Summary: A development tool for LLM call visualization and debugging
|
|
5
|
+
Requires-Python: >=3.10
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: pyyaml
|
|
8
|
+
Requires-Dist: dill
|
|
9
|
+
Requires-Dist: debugpy
|
|
10
|
+
Requires-Dist: psutil
|
|
11
|
+
Requires-Dist: psycopg2-binary
|
|
12
|
+
Requires-Dist: python-dotenv
|
|
13
|
+
Requires-Dist: fastapi
|
|
14
|
+
Requires-Dist: flatten_dict
|
|
15
|
+
Requires-Dist: flatten_json
|
|
16
|
+
Provides-Extra: dev
|
|
17
|
+
Requires-Dist: black==25.1.0; extra == "dev"
|
|
18
|
+
Requires-Dist: pytest; extra == "dev"
|
|
19
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
20
|
+
Requires-Dist: responses; extra == "dev"
|
|
21
|
+
Requires-Dist: openai; extra == "dev"
|
|
22
|
+
Requires-Dist: anthropic; extra == "dev"
|
|
23
|
+
Requires-Dist: openai-agents; extra == "dev"
|
|
24
|
+
Requires-Dist: google-genai; extra == "dev"
|
|
25
|
+
Requires-Dist: hydra-core; extra == "dev"
|
|
26
|
+
Requires-Dist: e2b_code_interpreter; extra == "dev"
|
|
27
|
+
Requires-Dist: together; extra == "dev"
|
|
28
|
+
Requires-Dist: langchain; extra == "dev"
|
|
29
|
+
Requires-Dist: langchain-anthropic; extra == "dev"
|
|
30
|
+
Requires-Dist: langchain-openai; extra == "dev"
|
|
31
|
+
Provides-Extra: examples
|
|
32
|
+
Requires-Dist: openai; extra == "examples"
|
|
33
|
+
Requires-Dist: anthropic; extra == "examples"
|
|
34
|
+
Requires-Dist: openai-agents; extra == "examples"
|
|
35
|
+
Requires-Dist: google-genai; extra == "examples"
|
|
36
|
+
Provides-Extra: docs
|
|
37
|
+
Requires-Dist: mkdocs-material>=9.5; extra == "docs"
|
|
38
|
+
Requires-Dist: mkdocs-minify-plugin; extra == "docs"
|
|
39
|
+
Requires-Dist: mkdocstrings[python]>=0.24; extra == "docs"
|
|
40
|
+
|
|
41
|
+
This tool allows you to visualize and edit your agent trajectories. Check out https://github.com/agent-ops-project/agent-dev for more details!
|
ao_dev-0.0.3/README.md
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# AO Agent Dev: What-if Questions over Agent Trajectories
|
|
2
|
+
|
|
3
|
+
AO Agent Dev is a developer tool for agent builders. It supports arbitrary Python progams (like your existing ones!) and will visualize your agent's LLM and MCP calls into a dataflow graph. You can then inspect, edit and rerun this graph and understand how to fix your agent.
|
|
4
|
+
|
|
5
|
+
[](https://youtu.be/woVctiSRJU0)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## Quickstart
|
|
9
|
+
|
|
10
|
+
`AO Agent Dev` integrates into VS Code or IDEs based on it, like Cursor. Simply download our [VS Code Extension](https://marketplace.visualstudio.com/items?itemName=agentops.ao-agent-dev) and install our pip package:
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pip install ao-agent-dev
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Then, give it a spin:
|
|
17
|
+
|
|
18
|
+
#### 1. Create an Example Project
|
|
19
|
+
|
|
20
|
+
Create a folder called `my-agent` and add a file called `openai_example.py` with the following content:
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from openai import OpenAI
|
|
24
|
+
|
|
25
|
+
def main():
|
|
26
|
+
client = OpenAI()
|
|
27
|
+
|
|
28
|
+
response = client.responses.create(
|
|
29
|
+
model="gpt-4o-mini",
|
|
30
|
+
input="Output the number 42 and nothing else",
|
|
31
|
+
temperature=0
|
|
32
|
+
)
|
|
33
|
+
number = response.output_text
|
|
34
|
+
|
|
35
|
+
prompt_add_1 = f"Add 1 to {number} and just output the result."
|
|
36
|
+
prompt_add_2 = f"Add 2 to {number} and just output the result."
|
|
37
|
+
|
|
38
|
+
response1 = client.responses.create(model="gpt-4o-mini", input=prompt_add_1, temperature=0)
|
|
39
|
+
response2 = client.responses.create(model="gpt-4o-mini", input=prompt_add_2, temperature=0)
|
|
40
|
+
|
|
41
|
+
sum_prompt = f"Add these two numbers together and just output the result: {response1.output_text} + {response2.output_text}"
|
|
42
|
+
final_sum = client.responses.create(model="gpt-4o-mini", input=sum_prompt, temperature=0)
|
|
43
|
+
|
|
44
|
+
print(f"Final sum: {final_sum.output_text}")
|
|
45
|
+
|
|
46
|
+
if __name__ == "__main__":
|
|
47
|
+
main()
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Run the script to verify it works:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
cd my-agent
|
|
54
|
+
python openai_example.py
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
#### 2. Configure AO
|
|
58
|
+
|
|
59
|
+
Run `ao-config` and set the project root to your `my-agent` folder:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
ao-config
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
#### 3. Run an example
|
|
66
|
+
|
|
67
|
+
Open your `my-agent` folder in VS Code, then run the example with AO in the terminal:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
ao-record openai_example.py
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The VS Code extension will display the dataflow graph showing how data flows between the LLM calls.
|
|
74
|
+
|
|
75
|
+
## Documentation
|
|
76
|
+
|
|
77
|
+
For complete documentation, installation guides, and tutorials, visit our **[Documentation Site](https://ao-agent-ops.github.io/ao-dev/)**.
|
|
78
|
+
|
|
79
|
+
## Building from source and developing
|
|
80
|
+
|
|
81
|
+
See the [Installation Guide](https://ao-agent-ops.github.io/ao-dev/getting-started/installation/) for development setup and the [Developer Guide](https://ao-agent-ops.github.io/ao-dev/developer-guide/architecture/) for architecture details.
|
|
82
|
+
|
|
83
|
+
## Community
|
|
84
|
+
|
|
85
|
+
- [Join our Discord](https://discord.gg/fjsNSa6TAh)
|
|
86
|
+
- [GitHub Issues](https://github.com/agent-ops-project/ao-dev/issues)
|
|
87
|
+
- We're just getting started on this tool and are eager to hear your feedback and resolve issues you ran into! We hope you enjoy it as much as we do.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ao-dev
|
|
3
|
+
Version: 0.0.3
|
|
4
|
+
Summary: A development tool for LLM call visualization and debugging
|
|
5
|
+
Requires-Python: >=3.10
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: pyyaml
|
|
8
|
+
Requires-Dist: dill
|
|
9
|
+
Requires-Dist: debugpy
|
|
10
|
+
Requires-Dist: psutil
|
|
11
|
+
Requires-Dist: psycopg2-binary
|
|
12
|
+
Requires-Dist: python-dotenv
|
|
13
|
+
Requires-Dist: fastapi
|
|
14
|
+
Requires-Dist: flatten_dict
|
|
15
|
+
Requires-Dist: flatten_json
|
|
16
|
+
Provides-Extra: dev
|
|
17
|
+
Requires-Dist: black==25.1.0; extra == "dev"
|
|
18
|
+
Requires-Dist: pytest; extra == "dev"
|
|
19
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
20
|
+
Requires-Dist: responses; extra == "dev"
|
|
21
|
+
Requires-Dist: openai; extra == "dev"
|
|
22
|
+
Requires-Dist: anthropic; extra == "dev"
|
|
23
|
+
Requires-Dist: openai-agents; extra == "dev"
|
|
24
|
+
Requires-Dist: google-genai; extra == "dev"
|
|
25
|
+
Requires-Dist: hydra-core; extra == "dev"
|
|
26
|
+
Requires-Dist: e2b_code_interpreter; extra == "dev"
|
|
27
|
+
Requires-Dist: together; extra == "dev"
|
|
28
|
+
Requires-Dist: langchain; extra == "dev"
|
|
29
|
+
Requires-Dist: langchain-anthropic; extra == "dev"
|
|
30
|
+
Requires-Dist: langchain-openai; extra == "dev"
|
|
31
|
+
Provides-Extra: examples
|
|
32
|
+
Requires-Dist: openai; extra == "examples"
|
|
33
|
+
Requires-Dist: anthropic; extra == "examples"
|
|
34
|
+
Requires-Dist: openai-agents; extra == "examples"
|
|
35
|
+
Requires-Dist: google-genai; extra == "examples"
|
|
36
|
+
Provides-Extra: docs
|
|
37
|
+
Requires-Dist: mkdocs-material>=9.5; extra == "docs"
|
|
38
|
+
Requires-Dist: mkdocs-minify-plugin; extra == "docs"
|
|
39
|
+
Requires-Dist: mkdocstrings[python]>=0.24; extra == "docs"
|
|
40
|
+
|
|
41
|
+
This tool allows you to visualize and edit your agent trajectories. Check out https://github.com/agent-ops-project/agent-dev for more details!
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
ao_dev.egg-info/PKG-INFO
|
|
4
|
+
ao_dev.egg-info/SOURCES.txt
|
|
5
|
+
ao_dev.egg-info/dependency_links.txt
|
|
6
|
+
ao_dev.egg-info/entry_points.txt
|
|
7
|
+
ao_dev.egg-info/requires.txt
|
|
8
|
+
ao_dev.egg-info/top_level.txt
|
|
9
|
+
docs/PKG_README.md
|
|
10
|
+
src/__init__.py
|
|
11
|
+
src/cli/__init__.py
|
|
12
|
+
src/cli/ao_config.py
|
|
13
|
+
src/cli/ao_record.py
|
|
14
|
+
src/cli/ao_server.py
|
|
15
|
+
src/common/__init__.py
|
|
16
|
+
src/common/config.py
|
|
17
|
+
src/common/constants.py
|
|
18
|
+
src/common/logger.py
|
|
19
|
+
src/common/utils.py
|
|
20
|
+
src/runner/__init__.py
|
|
21
|
+
src/runner/agent_runner.py
|
|
22
|
+
src/runner/ast_rewrite_hook.py
|
|
23
|
+
src/runner/context_manager.py
|
|
24
|
+
src/runner/taint_dict.py
|
|
25
|
+
src/runner/monkey_patching/__init__.py
|
|
26
|
+
src/runner/monkey_patching/api_parser.py
|
|
27
|
+
src/runner/monkey_patching/apply_monkey_patches.py
|
|
28
|
+
src/runner/monkey_patching/patching_utils.py
|
|
29
|
+
src/runner/monkey_patching/api_parsers/__init__.py
|
|
30
|
+
src/runner/monkey_patching/api_parsers/genai_api_parser.py
|
|
31
|
+
src/runner/monkey_patching/api_parsers/httpx_api_parser.py
|
|
32
|
+
src/runner/monkey_patching/api_parsers/mcp_api_parser.py
|
|
33
|
+
src/runner/monkey_patching/api_parsers/requests_api_parser.py
|
|
34
|
+
src/runner/monkey_patching/patches/__init__.py
|
|
35
|
+
src/runner/monkey_patching/patches/file_patches.py
|
|
36
|
+
src/runner/monkey_patching/patches/genai_patch.py
|
|
37
|
+
src/runner/monkey_patching/patches/httpx_patch.py
|
|
38
|
+
src/runner/monkey_patching/patches/mcp_patches.py
|
|
39
|
+
src/runner/monkey_patching/patches/randomness_patch.py
|
|
40
|
+
src/runner/monkey_patching/patches/requests_patch.py
|
|
41
|
+
src/server/__init__.py
|
|
42
|
+
src/server/ast_helpers.py
|
|
43
|
+
src/server/ast_transformer.py
|
|
44
|
+
src/server/auth_app.py
|
|
45
|
+
src/server/database_manager.py
|
|
46
|
+
src/server/file_watcher.py
|
|
47
|
+
src/server/main_server.py
|
|
48
|
+
src/server/database_backends/__init__.py
|
|
49
|
+
src/server/database_backends/postgres.py
|
|
50
|
+
src/server/database_backends/sqlite.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
pyyaml
|
|
2
|
+
dill
|
|
3
|
+
debugpy
|
|
4
|
+
psutil
|
|
5
|
+
psycopg2-binary
|
|
6
|
+
python-dotenv
|
|
7
|
+
fastapi
|
|
8
|
+
flatten_dict
|
|
9
|
+
flatten_json
|
|
10
|
+
|
|
11
|
+
[dev]
|
|
12
|
+
black==25.1.0
|
|
13
|
+
pytest
|
|
14
|
+
pre-commit
|
|
15
|
+
responses
|
|
16
|
+
openai
|
|
17
|
+
anthropic
|
|
18
|
+
openai-agents
|
|
19
|
+
google-genai
|
|
20
|
+
hydra-core
|
|
21
|
+
e2b_code_interpreter
|
|
22
|
+
together
|
|
23
|
+
langchain
|
|
24
|
+
langchain-anthropic
|
|
25
|
+
langchain-openai
|
|
26
|
+
|
|
27
|
+
[docs]
|
|
28
|
+
mkdocs-material>=9.5
|
|
29
|
+
mkdocs-minify-plugin
|
|
30
|
+
mkdocstrings[python]>=0.24
|
|
31
|
+
|
|
32
|
+
[examples]
|
|
33
|
+
openai
|
|
34
|
+
anthropic
|
|
35
|
+
openai-agents
|
|
36
|
+
google-genai
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ao
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This tool allows you to visualize and edit your agent trajectories. Check out https://github.com/agent-ops-project/agent-dev for more details!
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# pyproject.toml
|
|
2
|
+
|
|
3
|
+
[build-system]
|
|
4
|
+
requires = ["setuptools"]
|
|
5
|
+
build-backend = "setuptools.build_meta"
|
|
6
|
+
|
|
7
|
+
[tool.setuptools]
|
|
8
|
+
# Map ao package to src directory with subpackages
|
|
9
|
+
package-dir = {"ao" = "src"}
|
|
10
|
+
packages = [
|
|
11
|
+
"ao",
|
|
12
|
+
"ao.cli",
|
|
13
|
+
"ao.common",
|
|
14
|
+
"ao.runner",
|
|
15
|
+
"ao.runner.monkey_patching",
|
|
16
|
+
"ao.runner.monkey_patching.api_parsers",
|
|
17
|
+
"ao.runner.monkey_patching.patches",
|
|
18
|
+
"ao.server",
|
|
19
|
+
"ao.server.database_backends"
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
[project.scripts]
|
|
23
|
+
# Console commands for the ao package
|
|
24
|
+
ao-record = "ao.cli.ao_record:main"
|
|
25
|
+
ao-config = "ao.cli.ao_config:main"
|
|
26
|
+
ao-server = "ao.cli.ao_server:main"
|
|
27
|
+
|
|
28
|
+
# Aliases for quick access
|
|
29
|
+
record = "ao.cli.ao_record:main"
|
|
30
|
+
server = "ao.cli.ao_server:main"
|
|
31
|
+
|
|
32
|
+
[tool.black]
|
|
33
|
+
line-length = 100
|
|
34
|
+
|
|
35
|
+
[project]
|
|
36
|
+
name = "ao-dev"
|
|
37
|
+
version = "0.0.3"
|
|
38
|
+
description = "A development tool for LLM call visualization and debugging"
|
|
39
|
+
readme = "docs/PKG_README.md"
|
|
40
|
+
requires-python = ">=3.10"
|
|
41
|
+
|
|
42
|
+
dependencies = [
|
|
43
|
+
"pyyaml",
|
|
44
|
+
"dill",
|
|
45
|
+
"debugpy",
|
|
46
|
+
"psutil",
|
|
47
|
+
"psycopg2-binary",
|
|
48
|
+
"python-dotenv",
|
|
49
|
+
"fastapi",
|
|
50
|
+
"flatten_dict",
|
|
51
|
+
"flatten_json"
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
[project.optional-dependencies]
|
|
55
|
+
dev = [
|
|
56
|
+
"black==25.1.0",
|
|
57
|
+
"pytest",
|
|
58
|
+
"pre-commit",
|
|
59
|
+
"responses",
|
|
60
|
+
"openai",
|
|
61
|
+
"anthropic",
|
|
62
|
+
"openai-agents",
|
|
63
|
+
"google-genai",
|
|
64
|
+
"hydra-core",
|
|
65
|
+
"e2b_code_interpreter",
|
|
66
|
+
"together",
|
|
67
|
+
"langchain",
|
|
68
|
+
"langchain-anthropic",
|
|
69
|
+
"langchain-openai"
|
|
70
|
+
]
|
|
71
|
+
|
|
72
|
+
examples = [
|
|
73
|
+
"openai",
|
|
74
|
+
"anthropic",
|
|
75
|
+
"openai-agents",
|
|
76
|
+
"google-genai"
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
docs = [
|
|
80
|
+
"mkdocs-material>=9.5",
|
|
81
|
+
"mkdocs-minify-plugin",
|
|
82
|
+
"mkdocstrings[python]>=0.24",
|
|
83
|
+
]
|
ao_dev-0.0.3/setup.cfg
ADDED
|
File without changes
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Register taint functions in builtins BEFORE any other imports
|
|
2
|
+
import builtins
|
|
3
|
+
from ao.server.ast_helpers import (
|
|
4
|
+
taint_fstring_join,
|
|
5
|
+
taint_format_string,
|
|
6
|
+
taint_percent_format,
|
|
7
|
+
exec_func,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
builtins.taint_fstring_join = taint_fstring_join
|
|
11
|
+
builtins.taint_format_string = taint_format_string
|
|
12
|
+
builtins.taint_percent_format = taint_percent_format
|
|
13
|
+
builtins.exec_func = exec_func
|
|
14
|
+
|
|
15
|
+
import argparse
|
|
16
|
+
import os
|
|
17
|
+
from ao.common.config import (
|
|
18
|
+
Config,
|
|
19
|
+
_ask_field,
|
|
20
|
+
_convert_to_valid_path,
|
|
21
|
+
)
|
|
22
|
+
from ao.common.constants import AO_CONFIG, AO_PROJECT_ROOT
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def get_user_input() -> Config:
|
|
26
|
+
project_root = _ask_field(
|
|
27
|
+
f"What is the root directory of your project? [{AO_PROJECT_ROOT}]\n> ",
|
|
28
|
+
_convert_to_valid_path,
|
|
29
|
+
default=AO_PROJECT_ROOT,
|
|
30
|
+
error_message="Please enter a valid path to a directory.",
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
database_url = _ask_field(
|
|
34
|
+
"Database URL (leave empty for SQLite)\n> ",
|
|
35
|
+
str,
|
|
36
|
+
default=os.environ.get("DATABASE_URL"),
|
|
37
|
+
error_message="Please enter a valid database URL or leave empty.",
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
config = Config(
|
|
41
|
+
project_root=project_root,
|
|
42
|
+
database_url=database_url,
|
|
43
|
+
)
|
|
44
|
+
return config
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def config_command():
|
|
48
|
+
config = get_user_input()
|
|
49
|
+
config_file = AO_CONFIG
|
|
50
|
+
config.to_yaml_file(config_file)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def config_command_parser():
|
|
54
|
+
description = (
|
|
55
|
+
"Run `ao config` before you debug your agents. This "
|
|
56
|
+
"will prompt some configurations that you can choose. "
|
|
57
|
+
"These will get saved in a default path or in --config_path "
|
|
58
|
+
"which you can pass: `ao config --config_path some/path/config.yaml"
|
|
59
|
+
)
|
|
60
|
+
parser = argparse.ArgumentParser("Config", usage="ao-config", description=description)
|
|
61
|
+
return parser
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def main():
|
|
65
|
+
parser = config_command_parser()
|
|
66
|
+
parser.parse_args()
|
|
67
|
+
config_command()
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
if __name__ == "__main__":
|
|
71
|
+
main()
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import time
|
|
3
|
+
import yaml
|
|
4
|
+
from argparse import ArgumentParser, REMAINDER
|
|
5
|
+
from ao.common.constants import AO_CONFIG
|
|
6
|
+
from ao.runner.agent_runner import AgentRunner
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def launch_command_parser():
|
|
10
|
+
parser = ArgumentParser(
|
|
11
|
+
usage="ao-record <script.py> [<args>]",
|
|
12
|
+
description="Launch a python script with the AO under the hood.",
|
|
13
|
+
allow_abbrev=False,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
parser.add_argument(
|
|
17
|
+
"--config-file",
|
|
18
|
+
default=None,
|
|
19
|
+
help="The config file to use for the default values in the launching script.",
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
parser.add_argument(
|
|
23
|
+
"--run-name",
|
|
24
|
+
default=None,
|
|
25
|
+
help="Name that will be used in the experiment list. If not set, Run X where X is the index of the current run will be used.",
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
parser.add_argument(
|
|
29
|
+
"-m",
|
|
30
|
+
"--module",
|
|
31
|
+
action="store_true",
|
|
32
|
+
help="Change each process to interpret the launch script as a Python module, executing with the same behavior as 'python -m'.",
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
parser.add_argument(
|
|
36
|
+
"script_path",
|
|
37
|
+
type=str,
|
|
38
|
+
help="The full path to the script to be executed, followed by all the remaining arguments.",
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
parser.add_argument(
|
|
42
|
+
"script_args", nargs=REMAINDER, help="Arguments of the script to be executed."
|
|
43
|
+
)
|
|
44
|
+
return parser
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _validate_launch_command(args):
|
|
48
|
+
default_dict = {}
|
|
49
|
+
config_file = None
|
|
50
|
+
|
|
51
|
+
# check if the location of the config file is set
|
|
52
|
+
if args.config_file is not None and os.path.isfile(args.config_file):
|
|
53
|
+
config_file = args.config_file
|
|
54
|
+
# if not, check in the AOC_CONFIG path
|
|
55
|
+
elif os.path.isfile(AO_CONFIG):
|
|
56
|
+
config_file = AO_CONFIG
|
|
57
|
+
# if also not, it stays empty and we rely on the (default) args
|
|
58
|
+
|
|
59
|
+
if config_file is not None:
|
|
60
|
+
with open(config_file, encoding="utf-8") as f:
|
|
61
|
+
default_dict = yaml.safe_load(f)
|
|
62
|
+
|
|
63
|
+
# the arguments overwrite what is written in the config file
|
|
64
|
+
# that's why they come second.
|
|
65
|
+
args.__dict__ = {**default_dict, **args.__dict__}
|
|
66
|
+
# we don't need the config_file anymore and we don't
|
|
67
|
+
# want to confuse people with it still in the args:
|
|
68
|
+
del args.config_file
|
|
69
|
+
|
|
70
|
+
return args
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def launch_command(args):
|
|
74
|
+
args = _validate_launch_command(args)
|
|
75
|
+
|
|
76
|
+
agent_runner = AgentRunner(
|
|
77
|
+
script_path=args.script_path,
|
|
78
|
+
script_args=args.script_args,
|
|
79
|
+
is_module_execution=args.module,
|
|
80
|
+
run_name=args.run_name,
|
|
81
|
+
)
|
|
82
|
+
agent_runner.run()
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def main():
|
|
86
|
+
parser = launch_command_parser()
|
|
87
|
+
args = parser.parse_args()
|
|
88
|
+
launch_command(args)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
if __name__ == "__main__":
|
|
92
|
+
main()
|