1+ from __future__ import annotations
2+
13from enum import Enum
24from typing import Any , Dict
35from pathlib import Path
@@ -23,18 +25,14 @@ class TemplateType(str, Enum):
2325 SYNC = "sync"
2426
2527
26- def render_template (
27- template_path : str , context : Dict [str , Any ], template_type : TemplateType
28- ) -> str :
28+ def render_template (template_path : str , context : Dict [str , Any ], template_type : TemplateType ) -> str :
2929 """Render a template with the given context"""
3030 env = Environment (loader = FileSystemLoader (TEMPLATES_DIR / template_type .value ))
3131 template = env .get_template (template_path )
3232 return template .render (** context )
3333
3434
35- def create_project_structure (
36- path : Path , context : Dict [str , Any ], template_type : TemplateType , use_uv : bool
37- ):
35+ def create_project_structure (path : Path , context : Dict [str , Any ], template_type : TemplateType , use_uv : bool ):
3836 """Create the project structure from templates"""
3937 # Create project directory
4038 project_dir : Path = path / context ["project_name" ]
@@ -79,6 +77,9 @@ def create_project_structure(
7977 # Add development notebook for agents
8078 root_templates ["dev.ipynb.j2" ] = "dev.ipynb"
8179
80+ # Add test file
81+ root_templates ["test_agent.py.j2" ] = "test_agent.py"
82+
8283 for template , output in root_templates .items ():
8384 output_path = project_dir / output
8485 output_path .write_text (render_template (template , context , template_type ))
@@ -97,10 +98,7 @@ def get_project_context(answers: Dict[str, Any], project_path: Path, manifest_ro
9798 return {
9899 ** answers ,
99100 "project_name" : project_name ,
100- "workflow_class" : "" .join (
101- word .capitalize () for word in answers ["agent_name" ].split ("-" )
102- )
103- + "Workflow" ,
101+ "workflow_class" : "" .join (word .capitalize () for word in answers ["agent_name" ].split ("-" )) + "Workflow" ,
104102 "workflow_name" : answers ["agent_name" ],
105103 "queue_name" : project_name + "_queue" ,
106104 "project_path_from_build_root" : project_path_from_build_root ,
@@ -155,9 +153,7 @@ def validate_agent_name(text: str) -> bool | str:
155153 if not template_type :
156154 return
157155
158- project_path = questionary .path (
159- "Where would you like to create your project?" , default = "."
160- ).ask ()
156+ project_path = questionary .path ("Where would you like to create your project?" , default = "." ).ask ()
161157 if not project_path :
162158 return
163159
@@ -175,9 +171,7 @@ def validate_agent_name(text: str) -> bool | str:
175171 if not agent_directory_name :
176172 return
177173
178- description = questionary .text (
179- "Provide a brief description of your agent:" , default = "An AgentEx agent"
180- ).ask ()
174+ description = questionary .text ("Provide a brief description of your agent:" , default = "An AgentEx agent" ).ask ()
181175 if not description :
182176 return
183177
@@ -208,9 +202,7 @@ def validate_agent_name(text: str) -> bool | str:
208202 context ["use_uv" ] = answers ["use_uv" ]
209203
210204 # Create project structure
211- create_project_structure (
212- project_path , context , answers ["template_type" ], answers ["use_uv" ]
213- )
205+ create_project_structure (project_path , context , answers ["template_type" ], answers ["use_uv" ])
214206
215207 # Show next steps
216208 console .print ("\n [bold green]✨ Project created successfully![/bold green]" )
@@ -226,7 +218,8 @@ def validate_agent_name(text: str) -> bool | str:
226218 console .print ("4. Run locally:" )
227219 console .print (" agentex agents run --manifest manifest.yaml" )
228220
229- console .print ("5. Deploy your agent:" )
230- console .print (
231- " agentex agents deploy --cluster your-cluster --namespace your-namespace"
232- )
221+ console .print ("5. Test your agent:" )
222+ console .print (" pytest test_agent.py -v" )
223+
224+ console .print ("6. Deploy your agent:" )
225+ console .print (" agentex agents deploy --cluster your-cluster --namespace your-namespace" )
0 commit comments