Spaces:
Running
Installation and Configuration
Installation
Using Docker (Recommended for Local Development/Testing)
The easiest way to get Tensorus and its PostgreSQL backend running locally is by using Docker Compose:
- Ensure you have Docker and Docker Compose installed.
- Clone the repository (if applicable) or ensure you have the
docker-compose.ymland application files. - From the project root, run:
docker-compose up --build - The API will typically be available at
http://localhost:7860.
Manual Installation (From Source)
Ensure you have Python 3.10+ installed.
Clone the repository.
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activateInstall dependencies:
pip install -r requirements.txtHeavy machine-learning libraries used by the optional models are not installed by default. Install them with the
[models]extra when needed:pip install -e .[models]If you intend to run the test suite, also install the test requirements:
pip install -r requirements-test.txtThis ensures
fastapi>=0.110is installed so the API is compatible with Pydantic v2.(Optional) Install the example models package. The built-in models that were previously part of this repository now live at https://github.com/tensorus/models:
pip install tensorus-modelsSet up the necessary environment variables (see Configuration below).
Run the application using Uvicorn:
uvicorn tensorus.api:app --host 0.0.0.0 --port 7860This exposes all dataset and agent endpoints at
http://localhost:7860.
Configuration
Tensorus is configured via environment variables. Key variables include:
TENSORUS_STORAGE_BACKEND: Specifies the storage backend.in_memory(default): Uses in-memory storage (data is not persisted).postgres: Uses PostgreSQL.
TENSORUS_POSTGRES_HOST: Hostname for PostgreSQL (e.g.,localhostordbif using Docker Compose).TENSORUS_POSTGRES_PORT: Port for PostgreSQL (e.g.,5432).TENSORUS_POSTGRES_USER: Username for PostgreSQL.TENSORUS_POSTGRES_PASSWORD: Password for PostgreSQL.TENSORUS_POSTGRES_DB: Database name for PostgreSQL.TENSORUS_POSTGRES_DSN: Alternative DSN connection string for PostgreSQL.TENSORUS_VALID_API_KEYS: List of valid API keys. Values can be a comma-separated string (e.g.,key1,key2,anotherkey) or a JSON array. If no keys are required, set this to[].TENSORUS_API_KEY_HEADER_NAME: HTTP header name for the API key (default:X-API-KEY).TENSORUS_MINIMAL_IMPORT: Set to any value to skip importing the optionaltensorus-modelspackage for a lightweight installation.
JWT Authentication (Conceptual - For Future Use)
TENSORUS_AUTH_JWT_ENABLED:TrueorFalse(defaultFalse).TENSORUS_AUTH_JWT_ISSUER: URL of the JWT issuer.TENSORUS_AUTH_JWT_AUDIENCE: Expected audience for JWTs.TENSORUS_AUTH_JWT_ALGORITHM: Algorithm (defaultRS256).TENSORUS_AUTH_JWT_JWKS_URI: URI to fetch JWKS.TENSORUS_AUTH_DEV_MODE_ALLOW_DUMMY_JWT:Trueto allow dummy JWTs for development if JWT auth is enabled (defaultFalse).
Refer to the docker-compose.yml for example environment variable settings when running with Docker. For manual setup, export these variables in your shell or use a .env file (if your setup supports it, though direct environment variables are primary).
Running Tests
Tensorus includes Python unit tests. After installing the dependencies you can run them with:
pytest