Skip to content

Commit

Permalink
Merge pull request #1699 from Genez-io/cristim67/improv-streamlit-detect
Browse files Browse the repository at this point in the history
feat: add pyproject.toml support for Streamlit detection
  • Loading branch information
cristim67 authored Feb 6, 2025
2 parents 69f99c9 + 59cac74 commit 0eb3ee1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
8 changes: 5 additions & 3 deletions src/commands/analyze/frameworks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,10 +461,12 @@ export function isPythonLambdaFunction(contents: Record<string, string>): boolea
return contents["requirements.txt"] !== undefined || contents["pyproject.toml"] !== undefined;
}

// Checks if the project is a Streamlit component (presence of 'requirements.txt' and 'streamlit' in 'requirements.txt')
// Checks if the project is a Streamlit component (presence of 'requirements.txt' or 'pyproject.toml' and 'streamlit' in 'requirements.txt' or 'pyproject.toml')
export function isStreamlitComponent(contents: Record<string, string>): boolean {
return (
contents["requirements.txt"] !== undefined &&
contents["requirements.txt"].includes("streamlit")
(contents["requirements.txt"] !== undefined &&
contents["requirements.txt"].includes("streamlit")) ||
(contents["pyproject.toml"] !== undefined &&
contents["pyproject.toml"].includes("streamlit"))
);
}
23 changes: 17 additions & 6 deletions src/commands/deploy/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,23 @@ async function decideDeployType(options: GenezioDeployOptions): Promise<DeployTy
}
}

// Check if requirements.txt exists
if (fs.existsSync(path.join(cwd, "requirements.txt"))) {
// Check if streamlit is in the requirements.txt
const requirementsTxt = fs.readFileSync(path.join(cwd, "requirements.txt"), "utf-8");
if (requirementsTxt.includes("streamlit")) {
return [DeployType.Streamlit];
// Check if requirements.txt or pyproject.toml exists
if (
fs.existsSync(path.join(cwd, "requirements.txt")) ||
fs.existsSync(path.join(cwd, "pyproject.toml"))
) {
if (fs.existsSync(path.join(cwd, "requirements.txt"))) {
const requirementsTxt = fs.readFileSync(path.join(cwd, "requirements.txt"), "utf-8");
if (requirementsTxt.includes("streamlit")) {
return [DeployType.Streamlit];
}
}

if (fs.existsSync(path.join(cwd, "pyproject.toml"))) {
const pyprojectToml = fs.readFileSync(path.join(cwd, "pyproject.toml"), "utf-8");
if (pyprojectToml.includes("streamlit")) {
return [DeployType.Streamlit];
}
}
}

Expand Down

0 comments on commit 0eb3ee1

Please sign in to comment.