Skip to content

Commit

Permalink
Initial working version
Browse files Browse the repository at this point in the history
  • Loading branch information
nenb committed Jan 11, 2024
1 parent 20ecade commit b3122fa
Show file tree
Hide file tree
Showing 6 changed files with 642 additions and 2 deletions.
169 changes: 169 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
ragna.toml
ragna/_version.py

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/

# MacOS
**/.DS_Store

# VSCode
.vscode/
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM python:3.11

WORKDIR /opt/ragna

COPY requirements.txt .
RUN pip wheel --progress-bar=off --requirement requirements.txt

COPY ragna ./ragna
COPY pyproject.toml .
# Since we don't copy the .git folder, but still use setuptools-scm as build-backend
# we need to make two manual changes:
# 1. With setuptools-scm all files that are tracked by git are automatically included in
# the built wheel. Since we have corresponding .dockerignore file to our .gitignore,
# the ragna folder only includes files that we are tracking. Thus, we just include
# everything manually.
# 2. We need to pass the version expliclitly as
# --build-arg SETUPTOOLS_SCM_PRETEND_VERSION_FOR_RAGNA=...,
# since setuptools-scm cannot infer the version
RUN echo '[tool.setuptools.package-data]\n"*" = ["*"]' >> pyproject.toml
ARG SETUPTOOLS_SCM_PRETEND_VERSION_FOR_RAGNA
RUN pip install --progress-bar=off .[vectordb]

WORKDIR /var/ragna
COPY ragna-docker.toml ragna.toml
ENV RAGNA_CONFIG=/var/ragna/ragna.toml

ENTRYPOINT []
CMD ["ragna", "--help"]
50 changes: 50 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
version: "3"

services:
api.localhost:
build:
context: .
dockerfile: Dockerfile
args:
- SETUPTOOLS_SCM_PRETEND_VERSION_FOR_RAGNA=0.0.0
env_file: .env
environment: # overrides config in ragna-docker.toml
- "RAGNA_API_URL=http://0.0.0.0:31476"
- 'RAGNA_API_ORIGINS=["http://localhost:31477", "http://ui:31477"]'
command:
- ragna
- api
ports:
- "31476:31476"
healthcheck:
test: ["CMD", "curl", "http://0.0.0.0:31476"]
interval: 5s
timeout: 2s
retries: 6
# volumes:
# - "/tmp/ragna/documents:/var/ragna/documents"

ui:
build:
context: .
dockerfile: Dockerfile
args:
- SETUPTOOLS_SCM_PRETEND_VERSION_FOR_RAGNA=0.0.0
depends_on:
api.localhost:
condition: service_healthy
environment: # overrides config in ragna-docker.toml
- "RAGNA_API_URL=http://api.localhost:31476"
- "RAGNA_UI_URL=http://0.0.0.0:31477"
- 'RAGNA_UI_ORIGINS=["http://localhost:31477"]'
env_file: .env
command:
- ragna
- ui
ports:
- "31477:31477"
healthcheck:
test: ["CMD", "curl", "http://0.0.0.0:31477/health"]
interval: 5s
timeout: 2s
retries: 6
9 changes: 7 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,18 @@ Repository = "https://github.com/Quansight/ragna"

[project.optional-dependencies]
# to update the array below, run scripts/update_optional_dependencies.py
all = [
vectordb = [
"chromadb>=0.4.13",
"tiktoken",
]
lancedb = [
"lancedb>=0.2",
"pyarrow",
]
pdf = [
"pymupdf>=1.23.6",
"tiktoken",
]
all = ["ragna[vectordb,lancedb,pdf]"]

[tool.setuptools_scm]
write_to = "ragna/_version.py"
Expand Down
16 changes: 16 additions & 0 deletions ragna-docker.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
local_cache_root = "/var/ragna"
document = "ragna.core.LocalDocument"
authentication = "ragna.deploy._authentication.RagnaDemoAuthentication"

[components]
source_storages = ["ragna.source_storages.Chroma"]
assistants = ["ragna.assistants.Gpt4", "ragna.assistants.Gpt35Turbo16k"]

[api]
url = "http://0.0.0.0:31476"
origins = ["http://localhost:31477"]
database_url = "sqlite:////var/ragna/ragna.db"

[ui]
url = "http://0.0.0.0:31477"
origins = ["http://localhost:31477"]
Loading

0 comments on commit b3122fa

Please sign in to comment.