Backend API for the TORCHLITE application.
- Python 3.11 or higher.
- MongoDB (an alternative is to connect to an existing deployed MongoDB instance containing relevant data)
- Redis (an alternative is to connect to an existing deployed Redis instance)
- Docker is installed and running (recommended).
- Create a Python virtual environment
python3 -m venv .venv source .venv/bin/activate
- Install dependencies
pip install -r requirements.txt poetry lock --no-update poetry install
Create a .env
file in the root directory and add the following environment variables, and replace the placeholders with the actual values:
KEYCLOAK_REALM=<realm>
TORCHLITE_CLIENT_ID=<keycloak_client_id>
TORCHLITE_CLIENT_SECRET=<ckeycloak_lient_secret>
FEATURED_WORKSETS_URL=<url>
MONGODB_URL=<mongodb_url>
REDIS_HOST=<redis_host>
ENABLE_CACHE=<True/False>
CACHE_EXPIRE=<cache_expiration_time_in_seconds>
REGISTRY_API_URL=<registry_api_url>
FEATURED_WORKSET_USER=<featured_workset_user>
-
Build the Docker image
docker buildx build --no-cache -t torchlite-backend .
-
Run the TORCHLITE Backend using EITHER of the steps below.
a. Using Docker Run command. This assumes that MongoDB and Redis are running on the host machine.
docker run --env-file .env -p 8000:8000 torchlite-backend
b. Using Docker Compose (further testing and updating the instructions may be needed)
docker-compose up
- Run the application
poetry run uvicorn htrc.torchlite.app:api --reload --log-config log_conf.yaml
Open the API documentation in your browser at http://127.0.0.1:8000/docs.