-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
1,293 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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,38 @@ | ||
--- | ||
name: CI | ||
|
||
on: # yamllint disable-line rule:truthy | ||
push: | ||
paths-ignore: | ||
- README.md | ||
- LICENSE | ||
branches: | ||
- '**' | ||
|
||
jobs: | ||
test: | ||
name: Run Tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
lfs: true | ||
- name: Run tests | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.11' | ||
cache: 'pip' | ||
# Install poetry first, no virtualenv. | ||
- run: pip install -r poetry.txt | ||
- run: poetry config virtualenvs.create false | ||
# Install dependencies with poetry. | ||
- run: poetry install | ||
- name: Run pytest | ||
run: pytest | ||
- name: Run Pyright | ||
if: success() || failure() | ||
run: pyright | ||
- name: Run flake8 | ||
if: success() || failure() | ||
run: flake8 |
This file contains 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 @@ | ||
3.11.6 |
This file contains 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,8 @@ | ||
--- | ||
extends: default | ||
|
||
ignore: | | ||
.git | ||
.venv | ||
dist | ||
build |
This file contains 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,17 @@ | ||
FROM python:3.11 | ||
|
||
WORKDIR /code | ||
|
||
COPY ./pyproject.toml /code/pyproject.toml | ||
COPY ./poetry.lock /code/poetry.lock | ||
COPY ./poetry.txt /code/poetry.txt | ||
|
||
RUN pip install --no-cache-dir -r poetry.txt | ||
RUN poetry config virtualenvs.create false | ||
RUN poetry install --only main | ||
|
||
# Copy project directories after installation to use caching. | ||
COPY ./densechat_api /code/densechat_api | ||
|
||
EXPOSE 8000 | ||
CMD ["uvicorn", "densechat_api.api:app", "--host", "0.0.0.0", "--port", "8000"] |
This file contains 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 |
---|---|---|
@@ -1,2 +1,13 @@ | ||
# densechat-api | ||
A RestAPI for densechat.ai | ||
|
||
A RestAPI for [densechat.ai](https://densechat.ai). | ||
|
||
## Development | ||
|
||
Follow these steps to configure the project and run it locally. | ||
|
||
1. Check that your Python version matches the project: `cat .python-version` | ||
2. Install [poetry](https://python-poetry.org/): `python -m pip install -r poetry.txt` | ||
3. Run poetry: `poetry install` | ||
|
||
To update dependencies later, run `poetry update` and commit `poetry.lock`. |
Empty file.
This file contains 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,5 @@ | ||
from .main import app | ||
|
||
__all__ = [ | ||
'app', | ||
] |
This file contains 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,14 @@ | ||
from fastapi import FastAPI | ||
from starlette.responses import RedirectResponse | ||
|
||
app = FastAPI( | ||
title="densechat", | ||
description="The Densechat API.", | ||
version="0.1.0", | ||
) | ||
|
||
|
||
# Redirect / to /docs to make life easier for developers. | ||
@app.get('/', include_in_schema=False) | ||
async def index_view() -> RedirectResponse: | ||
return RedirectResponse('/docs', 302) |
Empty file.
This file contains 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,3 @@ | ||
""" | ||
Configuration for all tests. | ||
""" |
This file contains 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,3 @@ | ||
# A dummy test. | ||
def test_nothing(): | ||
pass |
This file contains 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,9 @@ | ||
services: | ||
app: | ||
build: . | ||
command: uvicorn densechat_api.api:app --host 0.0.0.0 --port 8000 --reload | ||
volumes: | ||
- ./densechat_api:/code/densechat_api | ||
ports: | ||
- 8000:8000 | ||
restart: unless-stopped |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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,3 @@ | ||
# Make poetry install files to ./.venv | ||
[virtualenvs] | ||
in-project = true |
This file contains 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,2 @@ | ||
# Install this file outside of virtualenv to set up poetry. | ||
poetry>=1.7.0 |
This file contains 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,56 @@ | ||
[tool.poetry] | ||
name = "densechat-api" | ||
version = "0.1.0" | ||
description = "An AI Rest API: https://densechat.ai" | ||
authors = ["Dense Analysis <[email protected]>"] | ||
|
||
[build-system] | ||
requires = ["poetry-core>=1.8.1"] | ||
build-backend = "poetry.core.masonry.api" | ||
|
||
# Base and Production-bound dependencies | ||
[tool.poetry.dependencies] | ||
python = "^3.11" | ||
# The API libray itself. | ||
fastapi = "^0.104.1" | ||
# Needed for running FastAPI via ASGI. | ||
uvicorn = {extras = ["standard"], version = "^0.22.0"} | ||
# requests will be needed to contact other APIs. | ||
requests = "^2.31.0" | ||
|
||
# Dependencies just for developer machines and CI. | ||
[tool.poetry.dev-dependencies] | ||
# pytest and useful pytest libraries and tools. | ||
pytest = "^7.4.0" | ||
pytest-cov = "4.1.0" | ||
pytest-mock = "3.11.1" | ||
pytest-asyncio = "0.21.0" | ||
requests-mock = "^1.7.0" | ||
# Linting and fixing code. | ||
flake8 = "6.0.0" | ||
isort = "5.12.0" | ||
flake8-isort = "6.1.0" | ||
# Type checking. | ||
pyright = "1.1.335" | ||
|
||
# isort settings, for sorting imports. | ||
[tool.isort] | ||
multi_line_output = 3 | ||
known_first_party = "densechat_api" | ||
skip = "migrations,.venv,typings" | ||
|
||
# Settings for type checking. | ||
[tool.pyright] | ||
venvPath = "./" | ||
venv = ".venv" | ||
pythonVersion = "3.11" | ||
reportMissingModuleSource = "error" | ||
typeCheckingMode = "strict" | ||
|
||
# Settings for pytest | ||
[tool.pytest] | ||
addopts = "--tb=short -vv" | ||
filterwarnings = [ | ||
# Report unhandled async code errors. | ||
"error::pytest.PytestUnhandledCoroutineWarning", | ||
] |
This file contains 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,3 @@ | ||
# flake8 doesn't support pyproject.toml yet. | ||
[flake8] | ||
exclude = .git,__pycache__,.venv |