Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
adubovik committed Oct 9, 2023
0 parents commit d680066
Show file tree
Hide file tree
Showing 68 changed files with 7,083 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
**/__pycache__
**/.venv
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/bin
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
**/.nox
LICENSE
.history
9 changes: 9 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Credentials for AWS account with an access to Bedrock models
AWS_ACCESS_KEY_ID=<key>
AWS_SECRET_ACCESS_KEY=<key>
DEFAULT_REGION=us-east-1

# Misc env vars for the server
LOG_LEVEL=INFO # Default in prod is INFO. Use DEBUG for dev.
WEB_CONCURRENCY=1 # Number of unicorn workers
TEST_SERVER_URL=http://0.0.0.0:5001
12 changes: 12 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[flake8]
# E501 line is too long
# W503 line break before binary operator
# E203 whitespace before ':'
ignore = E501, W503, E203
exclude =
.venv,
.nox,
__pycache__
per-file-ignores =
# imported but unused
tests/locust/app.py: F401
14 changes: 14 additions & 0 deletions .github/pr-title-checker-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"LABEL": {
"name": "",
"color": "EEEEEE"
},
"CHECKS": {
"prefixes": ["fix: ", "feat: ", "feature: ", "chore: ", "hotfix: "]
},
"MESSAGES": {
"success": "All OK",
"failure": "Missing prefix",
"notice": ""
}
}
15 changes: 15 additions & 0 deletions .github/workflows/pr_check_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Code checks - tests

on:
pull_request:
branches:
- development
- release-*

jobs:
run_tests:
uses: epam/ai-dial-ci/.github/workflows/test_python_docker.yml@0.1.0
with:
bypass_checks: false
python_version: 3.11
secrets: inherit
13 changes: 13 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Release version

on:
push:
branches: [ development, release-* ]

env:
IMAGE_NAME: ${{ github.repository }}

jobs:
release:
uses: epam/ai-dial-ci/.github/workflows/publish_python_docker.yml@0.1.0
secrets: inherit
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.DS_Store
venv
.venv
.env
.history
.idea
__pycache__
.nox
dist
.vscode/launch.json
~*
leftovers
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": [
"ms-python.python",
"ms-python.black-formatter",
"ms-python.isort"
]
}
14 changes: 14 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
"editor.tabSize": 4
},
"python.testing.pytestArgs": ["."],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.analysis.typeCheckingMode": "basic"
}
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM python:3.11-alpine as builder

RUN pip install poetry

WORKDIR /app

# Install split into two steps (the dependencies and the sources)
# in order to leverage the Docker caching
COPY pyproject.toml poetry.lock poetry.toml ./
RUN poetry install --no-interaction --no-ansi --no-cache --no-root --no-directory --only main

COPY . .
RUN poetry install --no-interaction --no-ansi --no-cache --only main

FROM python:3.11-alpine as server

WORKDIR /app

# Copy the sources and virtual env. No poetry.
RUN adduser -u 1001 --disabled-password --gecos "" appuser
COPY --chown=appuser --from=builder /app .

COPY ./scripts/docker_entrypoint.sh /docker_entrypoint.sh
RUN chmod +x /docker_entrypoint.sh

ENV LOG_LEVEL=INFO
EXPOSE 5000

USER appuser
ENTRYPOINT ["/docker_entrypoint.sh"]

CMD ["uvicorn", "aidial_adapter_bedrock.app:app", "--host", "0.0.0.0", "--port", "5000"]
29 changes: 29 additions & 0 deletions Dockerfile.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM python:3.11-slim as builder

RUN pip install poetry

WORKDIR /app

# Install split into two steps (the dependencies and the sources)
# in order to leverage the Docker caching
COPY pyproject.toml poetry.lock poetry.toml ./
RUN poetry install --no-interaction --no-ansi --no-cache --no-root --no-directory --with test

COPY . .
RUN poetry install --no-interaction --no-ansi --no-cache --with test

FROM python:3.11-slim as test

WORKDIR /app

# Copy the sources and virtual env. No poetry.
RUN adduser -u 1001 --disabled-password --gecos "" appuser
COPY --chown=appuser --from=builder /app .

COPY ./scripts/docker_entrypoint.sh /docker_entrypoint.sh
RUN chmod +x /docker_entrypoint.sh

USER appuser
ENTRYPOINT ["/docker_entrypoint.sh"]

CMD ["pytest", "tests/unit_tests"]
Loading

0 comments on commit d680066

Please sign in to comment.