-
Notifications
You must be signed in to change notification settings - Fork 182
feat: add test and fix python dependencies #304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
364d221
add test and fix deps
leehuwuj 3f2b434
add resolve-python-dependencies job
leehuwuj 89c1114
Only support python 3.11 and python 3.12 for now
leehuwuj 680c0fd
add web and db data source
leehuwuj 471aca2
remove python matrix for resolve-python-dependencies
leehuwuj b982e7a
ci: use only one e2e test
marcusschiesser File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
import { expect, test } from "@playwright/test"; | ||
import { exec } from "child_process"; | ||
import fs from "fs"; | ||
import path from "path"; | ||
import util from "util"; | ||
import { TemplateVectorDB } from "../helpers/types"; | ||
import { createTestDir, runCreateLlama } from "./utils"; | ||
|
||
const execAsync = util.promisify(exec); | ||
|
||
const vectorDbs: TemplateVectorDB[] = [ | ||
"mongo", | ||
"pg", | ||
"pinecone", | ||
"milvus", | ||
"astra", | ||
"qdrant", | ||
"chroma", | ||
"weaviate", | ||
]; | ||
|
||
const toolOptions = [ | ||
"wikipedia.WikipediaToolSpec", | ||
"google.GoogleSearchToolSpec", | ||
]; | ||
|
||
// TODO: Add data sources to the test | ||
|
||
test.describe("Test resolve python dependencies", () => { | ||
for (const vectorDb of vectorDbs) { | ||
for (const tool of toolOptions) { | ||
const optionDescription = `vectorDb: ${vectorDb}, tools: ${tool}`; | ||
|
||
test(`options: ${optionDescription}`, async () => { | ||
const cwd = await createTestDir(); | ||
|
||
const result = await runCreateLlama( | ||
cwd, | ||
"streaming", | ||
"fastapi", | ||
"--example-file", | ||
vectorDb, | ||
3000, // port | ||
8000, // externalPort | ||
"none", // postInstallAction | ||
undefined, // ui | ||
"--no-frontend", // appType | ||
undefined, // llamaCloudProjectName | ||
undefined, // llamaCloudIndexName | ||
tool, | ||
); | ||
const name = result.projectName; | ||
|
||
// Check if the app folder exists | ||
const dirExists = fs.existsSync(path.join(cwd, name)); | ||
expect(dirExists).toBeTruthy(); | ||
|
||
// Check if pyproject.toml exists | ||
const pyprojectPath = path.join(cwd, name, "pyproject.toml"); | ||
const pyprojectExists = fs.existsSync(pyprojectPath); | ||
expect(pyprojectExists).toBeTruthy(); | ||
|
||
// Run poetry lock | ||
try { | ||
const { stdout, stderr } = await execAsync( | ||
// Config poetry to create virtualenv in project directory. | ||
// so that we can easily prune the e2e cache to avoid overloading the storage. | ||
"poetry config virtualenvs.in-project true && poetry lock --no-update", | ||
{ | ||
cwd: path.join(cwd, name), | ||
}, | ||
); | ||
console.log("poetry lock stdout:", stdout); | ||
console.error("poetry lock stderr:", stderr); | ||
} catch (error) { | ||
console.error("Error running poetry lock:", error); | ||
throw error; | ||
} | ||
|
||
// Check if poetry.lock file was created | ||
const poetryLockExists = fs.existsSync( | ||
path.join(cwd, name, "poetry.lock"), | ||
); | ||
expect(poetryLockExists).toBeTruthy(); | ||
|
||
// Verify that specific dependencies are in pyproject.toml | ||
const pyprojectContent = fs.readFileSync(pyprojectPath, "utf-8"); | ||
if (vectorDb !== "none") { | ||
if (vectorDb === "pg") { | ||
expect(pyprojectContent).toContain( | ||
"llama-index-vector-stores-postgres", | ||
); | ||
} else { | ||
expect(pyprojectContent).toContain( | ||
`llama-index-vector-stores-${vectorDb}`, | ||
); | ||
} | ||
} | ||
marcusschiesser marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (tool !== "none") { | ||
if (tool === "wikipedia.WikipediaToolSpec") { | ||
expect(pyprojectContent).toContain("wikipedia"); | ||
} | ||
if (tool === "google.GoogleSearchToolSpec") { | ||
expect(pyprojectContent).toContain("google"); | ||
} | ||
} | ||
marcusschiesser marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
} | ||
} | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.