Environment:Vibrantlabsai Ragas Google Drive Backend Environment
| Knowledge Sources | |
|---|---|
| Domains | Infrastructure, Storage |
| Last Updated | 2026-02-12 10:00 GMT |
Overview
Google Drive backend environment requiring Google API client libraries and OAuth/service account credentials for storing Ragas datasets and experiments on Google Drive.
Description
The Google Drive backend (`GDriveBackend`) enables persistent storage of Ragas datasets and experiments as Google Sheets on Google Drive. It requires the Google API Python client library, authentication libraries, and either OAuth credentials or a service account JSON file. The backend creates a folder structure on Drive and manages spreadsheet-based storage with automatic schema handling.
Usage
Use this environment when you want to store and share Ragas datasets and experiment results on Google Drive. This is an optional backend; the default backends (InMemory, LocalCSV, LocalJSONL) do not require these dependencies. Activate this environment when using `ragas.backends.gdrive_backend.GDriveBackend`.
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| OS | Linux, macOS, Windows | Cross-platform support |
| Network | Internet access | Required for Google Drive API calls |
| Google Account | Google Workspace or personal account | Must have Drive access |
Dependencies
Python Packages
- `google-api-python-client` >= 2.178.0
- `google-auth` >= 2.40.3
- `google-auth-oauthlib` >= 1.2.2
Install via the optional dependency group:
pip install ragas[gdrive]
Credentials
The following environment variables configure Google Drive authentication:
- `GDRIVE_CREDENTIALS_PATH`: Path to the OAuth credentials JSON file (downloaded from Google Cloud Console).
- `GDRIVE_SERVICE_ACCOUNT_PATH`: Path to the service account JSON file (alternative to OAuth).
- `GDRIVE_TOKEN_PATH`: Path to store the OAuth token file (default: `token.json`).
Authentication Flow:
- If `service_account_path` is provided, service account auth is used (no browser required).
- If `credentials_path` is provided, OAuth flow runs (opens browser for consent on first use).
- The OAuth token is cached at `GDRIVE_TOKEN_PATH` for subsequent runs.
Quick Install
# Install Google Drive backend dependencies
pip install ragas[gdrive]
# Or install individually
pip install google-api-python-client>=2.178.0 google-auth>=2.40.3 google-auth-oauthlib>=1.2.2
# Set credentials
export GDRIVE_CREDENTIALS_PATH="/path/to/credentials.json"
# OR for service account
export GDRIVE_SERVICE_ACCOUNT_PATH="/path/to/service-account.json"
Code Evidence
Availability check from `src/ragas/backends/gdrive_backend.py:10-30`:
try:
from google.auth.transport.requests import Request
from google.oauth2.credentials import Credentials as UserCredentials
from google.oauth2.service_account import Credentials
from google_auth_oauthlib.flow import InstalledAppFlow
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
GDRIVE_AVAILABLE = True
except ImportError:
GDRIVE_AVAILABLE = False
Credential resolution from `src/ragas/backends/gdrive_backend.py:99-104`:
self.credentials_path = credentials_path or os.getenv("GDRIVE_CREDENTIALS_PATH")
self.service_account_path = service_account_path or os.getenv(
"GDRIVE_SERVICE_ACCOUNT_PATH"
)
self.token_path = token_path or os.getenv("GDRIVE_TOKEN_PATH", "token.json")
Import error on missing dependencies from `src/ragas/backends/gdrive_backend.py:91-95`:
if not GDRIVE_AVAILABLE:
raise ImportError(
"Google Drive backend requires additional dependencies. "
"Install with: pip install google-api-python-client google-auth google-auth-oauthlib"
)
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
| `ImportError: Google Drive backend requires additional dependencies` | Google API libraries not installed | `pip install ragas[gdrive]` |
| `FileNotFoundError: credentials.json` | OAuth credentials file not found at specified path | Download credentials from Google Cloud Console and set `GDRIVE_CREDENTIALS_PATH` |
| `HttpError 403: insufficient permissions` | Drive API not enabled or insufficient scopes | Enable Google Drive API in Cloud Console and re-authenticate |
Compatibility Notes
- Service Account vs OAuth: Service accounts are preferred for CI/CD pipelines (no browser required). OAuth is suitable for interactive use.
- Entry Point Registration: The backend is registered as `gdrive` via the `ragas.backends` entry point in `pyproject.toml`.