@@ -4,7 +4,7 @@ import fs from "fs";
4
4
import path from "path" ;
5
5
import util from "util" ;
6
6
import { TemplateFramework , TemplateVectorDB } from "../../helpers/types" ;
7
- import { createTestDir , runCreateLlama } from "../utils" ;
7
+ import { RunCreateLlamaOptions , createTestDir , runCreateLlama } from "../utils" ;
8
8
9
9
const execAsync = util . promisify ( exec ) ;
10
10
42
42
"--db-source mysql+pymysql://user:pass@localhost:3306/mydb" ,
43
43
] ;
44
44
45
+ const observabilityOptions = [ "llamatrace" , "traceloop" ] ;
46
+
47
+ // Run separate tests for each observability option to reduce CI runtime
48
+ test . describe ( "Test resolve python dependencies with observability" , ( ) => {
49
+ // Testing with streaming template, vectorDb: none, tools: none, and dataSource: --example-file
50
+ for ( const observability of observabilityOptions ) {
51
+ test ( `observability: ${ observability } ` , async ( ) => {
52
+ const cwd = await createTestDir ( ) ;
53
+
54
+ await createAndCheckLlamaProject ( {
55
+ options : {
56
+ cwd,
57
+ templateType : "streaming" ,
58
+ templateFramework,
59
+ dataSource,
60
+ vectorDb : "none" ,
61
+ tools : "none" ,
62
+ port : 3000 , // port, not used
63
+ externalPort : 8000 , // externalPort, not used
64
+ postInstallAction : "none" , // postInstallAction
65
+ templateUI : undefined , // ui
66
+ appType : "--no-frontend" , // appType
67
+ llamaCloudProjectName : undefined , // llamaCloudProjectName
68
+ llamaCloudIndexName : undefined , // llamaCloudIndexName
69
+ observability,
70
+ } ,
71
+ } ) ;
72
+ } ) ;
73
+ }
74
+ } ) ;
75
+
45
76
test . describe ( "Test resolve python dependencies" , ( ) => {
46
77
for ( const vectorDb of vectorDbs ) {
47
78
for ( const tool of toolOptions ) {
48
79
for ( const dataSource of dataSources ) {
49
80
const dataSourceType = dataSource . split ( " " ) [ 0 ] ;
50
- const optionDescription = `vectorDb: ${ vectorDb } , tools: ${ tool } , dataSource: ${ dataSourceType } ` ;
81
+ const toolDescription = tool === "none" ? "no tools" : tool ;
82
+ const optionDescription = `vectorDb: ${ vectorDb } , ${ toolDescription } , dataSource: ${ dataSourceType } ` ;
51
83
52
84
test ( `options: ${ optionDescription } ` , async ( ) => {
53
85
const cwd = await createTestDir ( ) ;
54
86
55
- const result = await runCreateLlama ( {
56
- cwd,
57
- templateType : "streaming" ,
58
- templateFramework,
59
- dataSource,
60
- vectorDb,
61
- port : 3000 , // port
62
- externalPort : 8000 , // externalPort
63
- postInstallAction : "none" , // postInstallAction
64
- templateUI : undefined , // ui
65
- appType : "--no-frontend" , // appType
66
- llamaCloudProjectName : undefined , // llamaCloudProjectName
67
- llamaCloudIndexName : undefined , // llamaCloudIndexName
68
- tools : tool ,
69
- } ) ;
70
- const name = result . projectName ;
71
-
72
- // Check if the app folder exists
73
- const dirExists = fs . existsSync ( path . join ( cwd , name ) ) ;
74
- expect ( dirExists ) . toBeTruthy ( ) ;
75
-
76
- // Check if pyproject.toml exists
77
- const pyprojectPath = path . join ( cwd , name , "pyproject.toml" ) ;
78
- const pyprojectExists = fs . existsSync ( pyprojectPath ) ;
79
- expect ( pyprojectExists ) . toBeTruthy ( ) ;
80
-
81
- // Run poetry lock
82
- try {
83
- const { stdout, stderr } = await execAsync (
84
- "poetry config virtualenvs.in-project true && poetry lock --no-update" ,
85
- {
86
- cwd : path . join ( cwd , name ) ,
87
+ const { pyprojectPath, projectPath } =
88
+ await createAndCheckLlamaProject ( {
89
+ options : {
90
+ cwd,
91
+ templateType : "streaming" ,
92
+ templateFramework,
93
+ dataSource,
94
+ vectorDb,
95
+ tools : tool ,
96
+ port : 3000 , // port, not used
97
+ externalPort : 8000 , // externalPort, not used
98
+ postInstallAction : "none" , // postInstallAction
99
+ templateUI : undefined , // ui
100
+ appType : "--no-frontend" , // appType
101
+ llamaCloudProjectName : undefined , // llamaCloudProjectName
102
+ llamaCloudIndexName : undefined , // llamaCloudIndexName
103
+ observability : undefined , // observability
87
104
} ,
88
- ) ;
89
- console . log ( "poetry lock stdout:" , stdout ) ;
90
- console . error ( "poetry lock stderr:" , stderr ) ;
91
- } catch ( error ) {
92
- console . error ( "Error running poetry lock:" , error ) ;
93
- throw error ;
94
- }
105
+ } ) ;
95
106
96
- // Check if poetry.lock file was created
97
- const poetryLockExists = fs . existsSync (
98
- path . join ( cwd , name , "poetry.lock" ) ,
99
- ) ;
100
- expect ( poetryLockExists ) . toBeTruthy ( ) ;
107
+ // Additional checks for specific dependencies
101
108
102
109
// Verify that specific dependencies are in pyproject.toml
103
110
const pyprojectContent = fs . readFileSync ( pyprojectPath , "utf-8" ) ;
@@ -136,3 +143,38 @@ if (
136
143
}
137
144
} ) ;
138
145
}
146
+
147
+ async function createAndCheckLlamaProject ( {
148
+ options,
149
+ } : {
150
+ options : RunCreateLlamaOptions ;
151
+ } ) : Promise < { pyprojectPath : string ; projectPath : string } > {
152
+ const result = await runCreateLlama ( options ) ;
153
+ const name = result . projectName ;
154
+ const projectPath = path . join ( options . cwd , name ) ;
155
+
156
+ // Check if the app folder exists
157
+ expect ( fs . existsSync ( projectPath ) ) . toBeTruthy ( ) ;
158
+
159
+ // Check if pyproject.toml exists
160
+ const pyprojectPath = path . join ( projectPath , "pyproject.toml" ) ;
161
+ expect ( fs . existsSync ( pyprojectPath ) ) . toBeTruthy ( ) ;
162
+
163
+ // Run poetry lock
164
+ try {
165
+ const { stdout, stderr } = await execAsync (
166
+ "poetry config virtualenvs.in-project true && poetry lock --no-update" ,
167
+ { cwd : projectPath } ,
168
+ ) ;
169
+ console . log ( "poetry lock stdout:" , stdout ) ;
170
+ console . error ( "poetry lock stderr:" , stderr ) ;
171
+ } catch ( error ) {
172
+ console . error ( "Error running poetry lock:" , error ) ;
173
+ throw error ;
174
+ }
175
+
176
+ // Check if poetry.lock file was created
177
+ expect ( fs . existsSync ( path . join ( projectPath , "poetry.lock" ) ) ) . toBeTruthy ( ) ;
178
+
179
+ return { pyprojectPath, projectPath } ;
180
+ }
0 commit comments