Skip to content

Restructure files #56

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 3 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
}
},
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "pip install -r requirements-dev.txt && pip install -e src",
"postCreateCommand": "pip install -r requirements-dev.txt && pip install -e src/backend && pip install -e src",
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
5 changes: 3 additions & 2 deletions .github/workflows/app-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,13 @@ jobs:
python -m pip install -r requirements-dev.txt
- name: Install app as editable app
run: |
python -m pip install -e src/backend
python -m pip install -e src
- name: Setup local database with seed data
run: |
cp .env.sample .env
python ./src/fastapi_app/setup_postgres_database.py
python ./src/fastapi_app/setup_postgres_seeddata.py
python ./src/backend/fastapi_app/setup_postgres_database.py
python ./src/backend/fastapi_app/setup_postgres_seeddata.py
- name: Setup node
uses: actions/setup-node@v4
with:
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@ Since the local app uses OpenAI models, you should first deploy it for the optim
1. Run these commands to install the web app as a local package (named `fastapi_app`), set up the local database, and seed it with test data:

```bash
python3 -m pip install -e src/backend
python3 -m pip install -e src
python ./src/fastapi_app/setup_postgres_database.py
python ./src/fastapi_app/setup_postgres_seeddata.py
python ./src/backend/fastapi_app/setup_postgres_database.py
python ./src/backend/fastapi_app/setup_postgres_seeddata.py
```

2. Build the frontend:
Expand All @@ -139,7 +140,7 @@ Since the local app uses OpenAI models, you should first deploy it for the optim
cd src/frontend
npm install
npm run build
cd ../..
cd ../../
```

There must be an initial build of static assets before running the backend, since the backend serves static files from the `src/static` directory.
Expand Down
2 changes: 1 addition & 1 deletion azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
template: rag-postgres-openai-python@0.0.1
services:
web:
project: ./src
project: ./src/backend
language: py
module: web
host: containerapp
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-r src/requirements.txt
-r src/backend/requirements.txt
ruff
pre-commit
pip-tools
Expand Down
1 change: 1 addition & 0 deletions scripts/load_python_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ echo 'Creating Python virtual environment in .venv...'
python3 -m venv .venv

echo 'Installing dependencies from "requirements.txt" into virtual environment (in quiet mode)...'
.venv/bin/python -m pip --quiet --disable-pip-version-check install -e src/backend
.venv/bin/python -m pip --quiet --disable-pip-version-check install -e src
.venv/bin/python -m pip --quiet --disable-pip-version-check install -r requirements-dev.txt
2 changes: 1 addition & 1 deletion scripts/setup_postgres_azurerole.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ if ([string]::IsNullOrEmpty($POSTGRES_HOST) -or [string]::IsNullOrEmpty($POSTGRE
exit 1
}

python ./src/fastapi_app/setup_postgres_azurerole.py --host $POSTGRES_HOST --username $POSTGRES_USERNAME --app-identity-name $APP_IDENTITY_NAME
python ./src/backend/fastapi_app/setup_postgres_azurerole.py --host $POSTGRES_HOST --username $POSTGRES_USERNAME --app-identity-name $APP_IDENTITY_NAME
2 changes: 1 addition & 1 deletion scripts/setup_postgres_azurerole.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ fi

. ./scripts/load_python_env.sh

.venv/bin/python ./src/fastapi_app/setup_postgres_azurerole.py --host $POSTGRES_HOST --username $POSTGRES_USERNAME --app-identity-name $APP_IDENTITY_NAME
.venv/bin/python ./src/backend/fastapi_app/setup_postgres_azurerole.py --host $POSTGRES_HOST --username $POSTGRES_USERNAME --app-identity-name $APP_IDENTITY_NAME
2 changes: 1 addition & 1 deletion scripts/setup_postgres_database.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ if ([string]::IsNullOrEmpty($POSTGRES_HOST) -or [string]::IsNullOrEmpty($POSTGRE
exit 1
}

python ./src/fastapi_app/setup_postgres_database.py --host $POSTGRES_HOST --username $POSTGRES_USERNAME --password $POSTGRES_PASSWORD
python ./backend/src/fastapi_app/setup_postgres_database.py --host $POSTGRES_HOST --username $POSTGRES_USERNAME --password $POSTGRES_PASSWORD
2 changes: 1 addition & 1 deletion scripts/setup_postgres_database.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ POSTGRES_DATABASE=$(azd env get-values | grep POSTGRES_DATABASE | sed 's/="/=/'

. ./scripts/load_python_env.sh

.venv/bin/python ./src/fastapi_app/setup_postgres_database.py --host $POSTGRES_HOST --username $POSTGRES_USERNAME --database $POSTGRES_DATABASE
.venv/bin/python ./src/backend/fastapi_app/setup_postgres_database.py --host $POSTGRES_HOST --username $POSTGRES_USERNAME --database $POSTGRES_DATABASE
2 changes: 1 addition & 1 deletion scripts/setup_postgres_seeddata.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ if ([string]::IsNullOrEmpty($POSTGRES_HOST) -or [string]::IsNullOrEmpty($POSTGRE
exit 1
}

python ./src/fastapi_app/setup_postgres_seeddata.py --host $POSTGRES_HOST --username $POSTGRES_USERNAME --password $POSTGRES_PASSWORD
python ./src/backend/fastapi_app/setup_postgres_seeddata.py --host $POSTGRES_HOST --username $POSTGRES_USERNAME --password $POSTGRES_PASSWORD
2 changes: 1 addition & 1 deletion scripts/setup_postgres_seeddata.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ POSTGRES_DATABASE=$(azd env get-values | grep POSTGRES_DATABASE | sed 's/="/=/'

. ./scripts/load_python_env.sh

.venv/bin/python ./src/fastapi_app/setup_postgres_seeddata.py --host $POSTGRES_HOST --username $POSTGRES_USERNAME --database $POSTGRES_DATABASE
.venv/bin/python ./src/backend/fastapi_app/setup_postgres_seeddata.py --host $POSTGRES_HOST --username $POSTGRES_USERNAME --database $POSTGRES_DATABASE
File renamed without changes.
File renamed without changes.
Empty file added src/backend/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 21 additions & 0 deletions src/backend/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[project]
name = "fastapi_app"
version = "1.0.0"
description = "Create a application with fastapi and postgres-flexible"
dependencies = [
"fastapi>=0.111.0,<1.0.0",
"python-dotenv>=1.0.1,<2.0.0",
"environs>=11.0.0,<12.0.0",
"azure-identity>=1.16.1,<2.0.0",
"aiohttp>=3.9.5,<4.0.0",
"asyncpg>=0.29.0,<1.0.0",
"SQLAlchemy[asyncio]>=2.0.30,<3.0.0",
"pgvector>=0.2.5,<0.3.0",
"openai>=1.34.0,<2.0.0",
"tiktoken>=0.7.0,<0.8.0",
"openai-messages-token-helper>=0.1.5,<0.2.0",
]

[build-system]
requires = ["flit_core<4"]
build-backend = "flit_core.buildapi"
File renamed without changes.
2 changes: 1 addition & 1 deletion src/frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import react from "@vitejs/plugin-react";
export default defineConfig({
plugins: [react()],
build: {
outDir: "../static",
outDir: "../backend/static",
emptyOutDir: true,
sourcemap: true,
rollupOptions: {
Expand Down
14 changes: 2 additions & 12 deletions src/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
[project]
name = "fastapi_app"
name = "backend"
version = "1.0.0"
description = "Create a application with fastapi and postgres-flexible"
dependencies = [
"fastapi>=0.111.0,<1.0.0",
"python-dotenv>=1.0.1,<2.0.0",
"environs>=11.0.0,<12.0.0",
"azure-identity>=1.16.1,<2.0.0",
"aiohttp>=3.9.5,<4.0.0",
"asyncpg>=0.29.0,<1.0.0",
"SQLAlchemy[asyncio]>=2.0.30,<3.0.0",
"pgvector>=0.2.5,<0.3.0",
"openai>=1.34.0,<2.0.0",
"tiktoken>=0.7.0,<0.8.0",
"openai-messages-token-helper>=0.1.5,<0.2.0",
"fastapi_app"
]

[build-system]
Expand Down