-
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.
Add elastic service and code of llm-pdf app
- Loading branch information
0 parents
commit d656e8c
Showing
18 changed files
with
915 additions
and
0 deletions.
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,37 @@ | ||
# Ignore Python cache files | ||
**/__pycache__ | ||
|
||
# Ignore pytest cache files | ||
.pytest_cache/ | ||
|
||
# Ignore ruff files | ||
.ruff_cache/ | ||
|
||
# Ignore git files | ||
.gitignore | ||
.github/ | ||
|
||
# Ignore Dockerfile and .dockerignore | ||
Dockerfile | ||
.dockerignore | ||
|
||
# Ignore other unnecessary files | ||
*.pyc | ||
*.pyo | ||
*.pyd | ||
*~ | ||
|
||
# Ignore makefile | ||
Makefile | ||
|
||
# Environment variables | ||
.envrc | ||
|
||
# Fly.io | ||
fly.toml | ||
|
||
# Elastic container config | ||
elastic/ | ||
|
||
# temporary data | ||
tmp/ |
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,4 @@ | ||
export STREAMLIT_SERVER_PORT=8000 | ||
export ELASTIC_URL='http://elacticserver:9200' | ||
export OPENAI_API_KEY='<<apikey here>>' | ||
export STREAMLIT_SERVER_COOKIE_SECRET='<<uuid here>>' |
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,43 @@ | ||
name: Fly Deploy | ||
on: | ||
push: | ||
branches: | ||
- 'master' | ||
env: | ||
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | ||
jobs: | ||
test: | ||
name: Run tests | ||
runs-on: ubuntu-latest | ||
env: | ||
STREAMLIT_SERVER_PORT: 8080 | ||
STREAMLIT_SERVER_COOKIE_SECRET: 00000000-0000-0000-0000-000000000000 | ||
OPENAI_API_KEY: nnn | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Restore asdf cache | ||
id: asdf-cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.asdf | ||
key: ${{ runner.os }}-asdf-${{ hashFiles('.tool-versions') }} | ||
- name: Install asdf | ||
uses: asdf-vm/actions/install@v3 | ||
- name: Restore poetry cache | ||
id: poetry-cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.cache/pypoetry | ||
key: ${{ runner.os }}-poetry-${{ hashFiles('pyproject.toml') }} | ||
- name: Install Dependencies | ||
run: make deps | ||
- name: Run Linter | ||
run: make lint | ||
deploy: | ||
name: Deploy to fly.io | ||
runs-on: ubuntu-latest | ||
needs: test | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: superfly/flyctl-actions/setup-flyctl@master | ||
- run: flyctl deploy --remote-only |
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,49 @@ | ||
# .gitignore | ||
__pycache__/ | ||
.pytest_cache/ | ||
.ruff_cache/ | ||
*.pyc | ||
*.pyo | ||
*.pyd | ||
*.pyc | ||
*.pyo | ||
*.pyd | ||
*.egg-info/ | ||
dist/ | ||
build/ | ||
*.egg | ||
*.log | ||
*.sql | ||
*.sqlite | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
|
||
# IDEs | ||
.idea/ | ||
*.swp | ||
*.swo | ||
*.swn | ||
*.pyc | ||
*.pyo | ||
*.pyd | ||
*.egg-info/ | ||
dist/ | ||
build/ | ||
*.egg | ||
*.log | ||
*.sql | ||
*.sqlite | ||
|
||
# Poetry | ||
/poetry.lock | ||
|
||
# Environment variables | ||
.envrc | ||
|
||
# temporary data | ||
tmp/ |
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 @@ | ||
[server] | ||
maxUploadSize = 3 |
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 @@ | ||
python 3.11.2 | ||
poetry 1.8.2 | ||
direnv 2.32.1 |
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,16 @@ | ||
# Use an official Python runtime as a parent image | ||
FROM python:3.11-slim-buster | ||
|
||
# Set the working directory in the container to /app | ||
WORKDIR /app | ||
|
||
# Add the current directory contents into the container at /app | ||
ADD . /app | ||
|
||
# Install any needed packages specified in pyproject.toml | ||
RUN pip install poetry | ||
RUN poetry config virtualenvs.create false | ||
RUN poetry install --no-dev | ||
|
||
# Run app.py when the container launches | ||
CMD poetry run streamlit run app.py |
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,22 @@ | ||
.PHONY: deps lint shell server server_headless test | ||
|
||
deps: | ||
poetry install | ||
|
||
lint: | ||
poetry run ruff check . | ||
|
||
shell: | ||
poetry run python | ||
|
||
server: | ||
poetry run streamlit run app.py | ||
|
||
server_headless: | ||
poetry run streamlit run app.py --browser.serverAddress 0.0.0.0 --server.headless true | ||
|
||
test: | ||
poetry run -- ptw -- -s -vv $(args) | ||
|
||
test_once: | ||
poetry run pytest -s |
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 src.llm_pdf import llm_pdf_app | ||
|
||
|
||
if __name__ == "__main__": | ||
llm_pdf_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,10 @@ | ||
# Use the official Elasticsearch image | ||
FROM docker.elastic.co/elasticsearch/elasticsearch:8.4.3 | ||
|
||
# Set environment variables | ||
ENV discovery.type=single-node | ||
ENV xpack.security.enabled=false | ||
|
||
# Expose ports | ||
EXPOSE 9200 | ||
EXPOSE 9300 |
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,25 @@ | ||
# fly.toml app configuration file generated for llm-pdf-elastic on 2024-06-20T15:19:26+02:00 | ||
# | ||
# See https://fly.io/docs/reference/configuration/ for information about how to use this file. | ||
# | ||
|
||
app = 'llm-pdf-elastic' | ||
primary_region = 'ams' | ||
|
||
[build] | ||
|
||
[http_service] | ||
internal_port = 9200 | ||
auto_stop_machines = true | ||
auto_start_machines = true | ||
min_machines_running = 1 | ||
processes = ['app'] | ||
|
||
[http_service.concurrency] | ||
type = 'requests' | ||
soft_limit = 250 | ||
|
||
[[vm]] | ||
memory = '1gb' | ||
cpu_kind = 'shared' | ||
cpus = 1 |
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 @@ | ||
#!/bin/bash | ||
fly proxy 19200:9200 -a llm-pdf-elastic |
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,48 @@ | ||
# fly.toml app configuration file generated for llm-pdf on 2024-06-21T08:48:12+02:00 | ||
# | ||
# See https://fly.io/docs/reference/configuration/ for information about how to use this file. | ||
# | ||
|
||
app = 'llm-pdf' | ||
primary_region = 'ams' | ||
kill_signal = 'SIGTERM' | ||
kill_timeout = '5s' | ||
|
||
[experimental] | ||
auto_rollback = true | ||
|
||
[build] | ||
|
||
[deploy] | ||
strategy = 'rolling' | ||
wait_timeout = '10m0s' | ||
|
||
[env] | ||
ELASTIC_URL = 'http://llm-pdf-elastic.internal:9200' | ||
HOST = 'llm-pdf.fly.dev' | ||
STREAMLIT_SERVER_PORT = '8080' | ||
|
||
[http_service] | ||
internal_port = 8080 | ||
force_https = true | ||
auto_stop_machines = true | ||
auto_start_machines = true | ||
min_machines_running = 1 | ||
processes = ['app'] | ||
|
||
[http_service.concurrency] | ||
type = 'connections' | ||
hard_limit = 1000 | ||
soft_limit = 1000 | ||
|
||
[[http_service.checks]] | ||
interval = '30s' | ||
timeout = '5s' | ||
grace_period = '10s' | ||
method = 'GET' | ||
path = '/' | ||
|
||
[[vm]] | ||
memory = '1024mb' | ||
cpu_kind = 'shared' | ||
cpus = 1 |
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,21 @@ | ||
[loggers] | ||
keys=root | ||
|
||
[handlers] | ||
keys=consoleHandler | ||
|
||
[formatters] | ||
keys=normalFormatter | ||
|
||
[logger_root] | ||
level=INFO | ||
handlers=consoleHandler | ||
|
||
[handler_consoleHandler] | ||
class=StreamHandler | ||
level=DEBUG | ||
formatter=normalFormatter | ||
args=(sys.stdout,) | ||
|
||
[formatter_normalFormatter] | ||
format=%(asctime)s loglevel=%(levelname)-6s logger=%(name)s %(message)s |
Oops, something went wrong.