The HTTP API used by http://playground.allenai.org
To start a local server, follow these steps:
-
Generate a local
config.jsonfile:./bin/bootstrap -
Next open another terminal and launch the application like so:
docker compose up --build --watch
This project uses uv. To run it locally, follow their installation guide.
After uv is installed, run uv sync --all-packages --all-groups at the root of this project.
We use uv's workspaces to split code into larger chunks.
To add a new package, cd to packages and run uv init --lib --package package-name. Make sure you run uv add package-name --package <DEPENDENT_PACKAGE> for any packages that depend on it.
To add a new app, cd to apps and run uv init app-name.
FastAPI app uses pydandantic settings to load settings, it has default values set in ./apps/api/src/api/config.py and loads
environment variables from .env, .env.local, .env.${ENV} and .env.${ENV}.local, with .local files being ignored
Public configuration variables should be stored in non-gitignored configs, with env agnostic configs in .env.
Secrets should be stored in .env.local (or .env.${ENV}.local) file.
The API uses a local database for persistence. If you'd like to delete all data or reapply the schema, run:
docker compose down --volumes && docker compose up --build
To run the Flask tests, execute:
FLASK_CONFIG_PATH="./test.config.json" uv run --python 3.11 pytest apps/flask-api -m "not integration"To run the FastAPI tests, execute
uv run pytest apps/apiTo check types run separately for api and flask-api:
uv run mypy apps/api packages
uv run mypy apps/flask-apiTo run the formatter / linter:
uv run ruff formatTo just check without making changes to the files:
uv run ruff format --checkTo check for linting issues in fastapi:
uv run ruff check --exclude ./apps/flask-apiOn macOS, ensure you have homebrew installed then run brew install ffmpeg
Change db.conninfo in config.json to "postgres://app:llmz@127.0.0.1:5555/llmx?sslmode=disable"
start the postgres container with docker compose up db
make sure you're in the venv by running .venv/bin/activate
Start the server by running FLASK_APP=app.py python -m flask run -p 8000
Note: If you run e2e tests with a local server it's possible for the containers and local server to be out of sync. Make sure you run e2e tests in the docker-compose
Ensure you have the Python Extension installed.
Instead of starting the server with the python command above, launch the Python Debugger: Flask debug task in VSCode's debug menu.
run openapi-python-client generate --url https://infinigram-api.allen.ai/openapi.json --overwrite
copy the infini_gram_api_client folder from the generated code into src/attribution/infini_gram_api_client