diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..b5db8d48 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +*.sh text eol=lf +*.jsonlines text eol=lf \ No newline at end of file diff --git a/.github/workflows/app-tests.yaml b/.github/workflows/app-tests.yaml old mode 100644 new mode 100755 index 3ef2409b..af4a2d37 --- a/.github/workflows/app-tests.yaml +++ b/.github/workflows/app-tests.yaml @@ -13,20 +13,34 @@ jobs: strategy: fail-fast: false matrix: - os: ["ubuntu-20.04"] + os: ["ubuntu-latest", "windows-latest", "macos-latest-xlarge", "macos-13"] python_version: ["3.10", "3.11", "3.12"] - services: - postgres: - image: pgvector/pgvector:pg16 - env: - POSTGRES_USER: admin - POSTGRES_PASSWORD: postgres - ports: - - 5432:5432 - # needed because the postgres container does not provide a healthcheck - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + exclude: + - os: macos-latest-xlarge + python_version: "3.10" steps: - uses: actions/checkout@v4 + - name: Check for MacOS Runner + if: matrix.os == 'macos-latest-xlarge' + run: brew install postgresql@14 + - name: Install pgvector on Windows using install-pgvector.bat + if: matrix.os == 'windows-latest' + shell: cmd + run: .github\workflows\install-pgvector.bat + - name: Install PostgreSQL development libraries + if: matrix.os == 'ubuntu-latest' + run: | + sudo apt update + sudo apt install postgresql-server-dev-14 + - name: Setup postgres + uses: ikalnytskyi/action-setup-postgres@v6 + with: + username: admin + password: postgres + database: postgres + - name: Install pgvector on MacOS/Linux using install-pgvector.sh + if: matrix.os != 'windows-latest' + run: .github/workflows/install-pgvector.sh - name: Setup python uses: actions/setup-python@v5 with: @@ -43,3 +57,12 @@ jobs: cp .env.sample .env python ./src/fastapi_app/setup_postgres_database.py python ./src/fastapi_app/setup_postgres_seeddata.py + - name: Setup node + uses: actions/setup-node@v4 + with: + node-version: 18 + - name: Build frontend + run: | + cd ./src/frontend + npm install + npm run build \ No newline at end of file diff --git a/.github/workflows/install-pgvector.bat b/.github/workflows/install-pgvector.bat new file mode 100644 index 00000000..56134c60 --- /dev/null +++ b/.github/workflows/install-pgvector.bat @@ -0,0 +1,8 @@ +set "PGROOT=C:\Program Files\PostgreSQL\14" +cd $RUNNER_TEMP +git clone --branch v0.6.2 https://github.com/pgvector/pgvector.git +cd pgvector + +call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" +nmake /NOLOGO /F Makefile.win +nmake /NOLOGO /F Makefile.win install \ No newline at end of file diff --git a/.github/workflows/install-pgvector.sh b/.github/workflows/install-pgvector.sh new file mode 100755 index 00000000..387f56b8 --- /dev/null +++ b/.github/workflows/install-pgvector.sh @@ -0,0 +1,5 @@ +cd /tmp +git clone --branch v0.7.2 https://github.com/pgvector/pgvector.git +cd pgvector +make +sudo make install # may need sudo \ No newline at end of file diff --git a/requirements-dev.txt b/requirements-dev.txt index 0924b724..d1c56a4b 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,3 +2,4 @@ ruff pre-commit pip-tools +pip-compile-cross-platform \ No newline at end of file diff --git a/src/entrypoint.sh b/src/entrypoint.sh index f3c4cea8..0a743968 100644 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -1,3 +1,4 @@ #!/bin/bash set -e +python3 -m pip install . python3 -m gunicorn "fastapi_app:create_app()" \ No newline at end of file diff --git a/src/pyproject.toml b/src/pyproject.toml index a4bb0de1..1d753fec 100644 --- a/src/pyproject.toml +++ b/src/pyproject.toml @@ -1,21 +1,19 @@ [project] name = "fastapi_app" version = "1.0.0" -description = "Create a relecloud demo application with fastapi and postgres-flexible" +description = "Create a application with fastapi and postgres-flexible" dependencies = [ - "fastapi", - "gunicorn", - "uvicorn[standard]", - "python-dotenv", - "environs", - "azure-identity", - "aiohttp", - "asyncpg", - "SQLAlchemy[asyncio]", - "pgvector", - "openai", - "tiktoken", - "openai-messages-token-helper" + "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] diff --git a/src/requirements.txt b/src/requirements.txt index 854d69d9..cf57fdaa 100644 --- a/src/requirements.txt +++ b/src/requirements.txt @@ -1,204 +1,2 @@ -# -# This file is autogenerated by pip-compile with Python 3.11 -# by the following command: -# -# pip-compile --output-file=requirements.txt pyproject.toml -# -aiohttp==3.9.5 - # via fastapi_app (pyproject.toml) -aiosignal==1.3.1 - # via aiohttp -annotated-types==0.7.0 - # via pydantic -anyio==4.4.0 - # via - # httpx - # openai - # starlette - # watchfiles -async-timeout==4.0.3 - # via asyncpg -asyncpg==0.29.0 - # via fastapi_app (pyproject.toml) -attrs==23.2.0 - # via aiohttp -azure-core==1.30.1 - # via azure-identity -azure-identity==1.16.0 - # via fastapi_app (pyproject.toml) -certifi==2024.2.2 - # via - # httpcore - # httpx - # requests -cffi==1.16.0 - # via cryptography -charset-normalizer==3.3.2 - # via requests -click==8.1.7 - # via - # typer - # uvicorn -cryptography==42.0.7 - # via - # azure-identity - # msal - # pyjwt -distro==1.9.0 - # via openai -dnspython==2.6.1 - # via email-validator -email-validator==2.1.1 - # via fastapi -environs==11.0.0 - # via fastapi_app (pyproject.toml) -fastapi==0.111.0 - # via fastapi_app (pyproject.toml) -fastapi-cli==0.0.4 - # via fastapi -frozenlist==1.4.1 - # via - # aiohttp - # aiosignal -greenlet==3.0.3 - # via sqlalchemy -gunicorn==22.0.0 - # via fastapi_app (pyproject.toml) -h11==0.14.0 - # via - # httpcore - # uvicorn -httpcore==1.0.5 - # via httpx -httptools==0.6.1 - # via uvicorn -httpx==0.27.0 - # via - # fastapi - # openai -idna==3.7 - # via - # anyio - # email-validator - # httpx - # requests - # yarl -jinja2==3.1.4 - # via fastapi -markdown-it-py==3.0.0 - # via rich -markupsafe==2.1.5 - # via jinja2 -marshmallow==3.21.2 - # via environs -mdurl==0.1.2 - # via markdown-it-py -msal==1.28.0 - # via - # azure-identity - # msal-extensions -msal-extensions==1.1.0 - # via azure-identity -multidict==6.0.5 - # via - # aiohttp - # yarl -numpy==1.26.4 - # via pgvector -openai==1.31.0 - # via - # fastapi_app (pyproject.toml) - # openai-messages-token-helper -openai-messages-token-helper==0.1.4 - # via fastapi_app (pyproject.toml) -orjson==3.10.3 - # via fastapi -packaging==24.0 - # via - # gunicorn - # marshmallow - # msal-extensions -pgvector==0.2.5 - # via fastapi_app (pyproject.toml) -pillow==10.3.0 - # via openai-messages-token-helper -portalocker==2.8.2 - # via msal-extensions -pycparser==2.22 - # via cffi -pydantic==2.7.2 - # via - # fastapi - # openai -pydantic-core==2.18.3 - # via pydantic -pygments==2.18.0 - # via rich -pyjwt[crypto]==2.8.0 - # via - # msal - # pyjwt -python-dotenv==1.0.1 - # via - # environs - # fastapi_app (pyproject.toml) - # uvicorn -python-multipart==0.0.9 - # via fastapi -pyyaml==6.0.1 - # via uvicorn -regex==2024.5.15 - # via tiktoken -requests==2.32.3 - # via - # azure-core - # msal - # tiktoken -rich==13.7.1 - # via typer -shellingham==1.5.4 - # via typer -six==1.16.0 - # via azure-core -sniffio==1.3.1 - # via - # anyio - # httpx - # openai -sqlalchemy[asyncio]==2.0.30 - # via fastapi_app (pyproject.toml) -starlette==0.37.2 - # via fastapi -tiktoken==0.7.0 - # via - # fastapi_app (pyproject.toml) - # openai-messages-token-helper -tqdm==4.66.4 - # via openai -typer==0.12.3 - # via fastapi-cli -typing-extensions==4.12.0 - # via - # azure-core - # fastapi - # openai - # pydantic - # pydantic-core - # sqlalchemy - # typer -ujson==5.10.0 - # via fastapi -urllib3==2.2.1 - # via requests -uvicorn[standard]==0.30.0 - # via - # fastapi - # fastapi_app (pyproject.toml) -uvloop==0.19.0 - # via uvicorn -watchfiles==0.22.0 - # via uvicorn -websockets==12.0 - # via uvicorn -yarl==1.9.4 - # via aiohttp +gunicorn>=22.0.0,<23.0.0 +uvicorn>=0.30.1,<1.0.0 \ No newline at end of file