Skip to content

Commit b918fc8

Browse files
committed
added dependecies to use full template
1 parent c5b32c4 commit b918fc8

File tree

2 files changed

+71
-19
lines changed

2 files changed

+71
-19
lines changed

create_fastapi_project/main.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,8 @@ def create_project():
4040
langchain_basic = ITemplate.langchain_basic.value
4141
full = ITemplate.full.value
4242
template_type: str = questionary.select(
43-
"Choose a template", choices=[
44-
basic,
45-
langchain_basic,
46-
questionary.Choice(full, disabled=disabled_message)
47-
]
43+
"Choose a template",
44+
choices=[basic, langchain_basic, full],
4845
).ask()
4946
if template_type == ITemplate.full:
5047
questionary.select(
@@ -79,9 +76,7 @@ def create_project():
7976
panel = Panel(styled_message, title="Project Initialization")
8077
console.print(panel)
8178

82-
confirmation: bool = questionary.confirm(
83-
"Are you sure you want to continue?"
84-
).ask()
79+
confirmation: bool = questionary.confirm("Are you sure you want to continue?").ask()
8580
if not confirmation:
8681
print("Not created")
8782
raise typer.Abort()

create_fastapi_project/templates/__init__.py

Lines changed: 68 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22
import shutil
33
from enum import Enum
44
from dotenv import dotenv_values
5-
from create_fastapi_project.helpers.install import add_configuration_to_pyproject, install_dependencies
5+
from create_fastapi_project.helpers.install import (
6+
add_configuration_to_pyproject,
7+
install_dependencies,
8+
)
9+
610

711
class ITemplate(str, Enum):
812
basic = "basic"
913
langchain_basic = "langchain_basic"
10-
full = "full"
14+
full = "full"
15+
1116

1217
def install_template(root: str, template: ITemplate, app_name: str):
1318
print(f"Initializing project with template: {template}")
@@ -32,45 +37,97 @@ def install_template(root: str, template: ITemplate, app_name: str):
3237
dirs_exist_ok=True,
3338
)
3439

35-
3640
poetry_path = ""
3741
if template == ITemplate.full or template == ITemplate.langchain_basic:
3842
# TODO: CHECK PATHS IN MACOS AND WINDOWS | (os.path.join)
3943
poetry_path = os.path.join(root, "backend", "app")
4044

4145
else:
4246
poetry_path = os.path.join(root, "app")
43-
47+
4448
has_pyproject = add_configuration_to_pyproject(poetry_path)
4549

4650
if has_pyproject:
47-
dependencies = ["fastapi[all]", "fastapi-pagination[sqlalchemy]@^0.12.7", "asyncer@^0.0.2", "httpx@^0.24.1"]
51+
dependencies = [
52+
"fastapi[all]",
53+
"fastapi-pagination[sqlalchemy]@^0.12.7",
54+
"asyncer@^0.0.2",
55+
"httpx@^0.24.1",
56+
]
57+
dev_dependencies = [
58+
"pytest@^7.4.0",
59+
"mypy@^1.5.0",
60+
"ruff@^0.0.284",
61+
"black@^23.7.0",
62+
]
4863
if template == ITemplate.langchain_basic:
4964
langchain_dependencies = [
5065
"langchain@^0.0.265",
5166
"openai@^0.27.8",
5267
"adaptive-cards-py@^0.0.7",
53-
"google-search-results@^2.4.2"
68+
"google-search-results@^2.4.2",
5469
]
5570
dependencies[0] = "fastapi[all]@^0.99.1"
5671
dependencies.extend(langchain_dependencies)
57-
dev_dependencies = ["pytest@^5.2", "mypy@^1.5.0", "ruff@^0.0.284", "black@^23.7.0"]
72+
if template == ITemplate.full:
73+
full_dependencies = [
74+
"alembic@^1.10.2",
75+
"asyncpg@^0.27.0",
76+
"sqlmodel@^0.0.8",
77+
"python-jose@^3.3.0",
78+
"cryptography@^38.0.3",
79+
"passlib@^1.7.4",
80+
"SQLAlchemy-Utils@^0.38.3",
81+
"SQLAlchemy@^1.4.40",
82+
"minio@^7.1.13",
83+
"Pillow@^9.4.0",
84+
"watchfiles@^0.18.1",
85+
"asyncer@^0.0.2",
86+
"httpx@^0.23.1",
87+
"pandas@^1.5.3",
88+
"openpyxl@^3.0.10",
89+
"redis@^4.5.1",
90+
"fastapi-async-sqlalchemy@^0.3.12",
91+
"oso@^0.26.4",
92+
"celery@^5.2.7",
93+
"transformers@^4.28.1",
94+
"requests@^2.29.0",
95+
"wheel@^0.40.0",
96+
"setuptools@^67.7.2",
97+
"langchain@^0.0.262",
98+
"openai@^0.27.5",
99+
"celery-sqlalchemy-scheduler@^0.3.0",
100+
"psycopg2-binary@^2.9.5",
101+
"fastapi-limiter@^0.1.5 ",
102+
# fastapi-pagination {extras ["sqlalchemy"], version "^0.11.4"},
103+
"fastapi-pagination[sqlalchemy]@^0.11.4 ",
104+
# fastapi-cache2 {extras ["redis"], version "^0.2.1"},
105+
"fastapi-cache2[redis]@^0.2.1 ",
106+
# torch [ {url "https://download.pytorch.org/whl/cpu/torch-2.0.0%2Bcpu-cp310-cp310-linux_x86_64.whl", markers "sys_platform 'linux'"},{url "https://download.pytorch.org/whl/cpu/torch-2.0.0%2Bcpu-cp310-cp310-win_amd64.whl", markers "sys_platform 'win32'"}],
107+
]
108+
full_dev_dependencies = [
109+
"pytest-asyncio@^0.21.1",
110+
]
111+
dependencies[0] = "fastapi[all]@^0.95.2"
112+
dependencies.extend(full_dependencies)
113+
dev_dependencies.extend(full_dev_dependencies)
114+
58115
print("- Installing main packages. This might take a couple of minutes.")
59116
install_dependencies(poetry_path, dependencies)
60117
print("- Installing development packages. This might take a couple of minutes.")
61118
install_dependencies(poetry_path, dev_dependencies, dev=True)
62119
# Set your dynamic environment variables
63-
120+
64121
# Load variables from .env.example
65122
example_env = dotenv_values(".env.example")
66123
example_env["PROJECT_NAME"] = app_name
67124

68125
# Write modified environment variables to .env and .env.example file
69-
with open(".env", "w") as env_file, open(".env.example", "w") as example_env_file:
126+
with open(".env", "w") as env_file, open(
127+
".env.example", "w"
128+
) as example_env_file:
70129
for key, value in example_env.items():
71130
env_file.write(f"{key}={value}\n")
72131
example_env_file.write(f"{key}={value}\n")
73132

74133
return has_pyproject
75-
76-

0 commit comments

Comments
 (0)