CSCS-DWDI reporting plugin for Waldur Site Agent
Project description
CSCS-DWDI Plugin for Waldur Site Agent
This plugin provides reporting functionality for Waldur Site Agent by integrating with the CSCS-DWDI (Data Warehouse and Data Intelligence) API.
Overview
The CSCS-DWDI plugin is a reporting-only backend that fetches compute usage data from the CSCS-DWDI service and reports it to Waldur. It supports node-hour usage tracking for multiple accounts and users.
Features
- Monthly Usage Reporting: Fetches usage data for the current month
- Multi-Account Support: Reports usage for multiple accounts in a single API call
- Per-User Usage: Breaks down usage by individual users within each account
- OIDC Authentication: Uses OAuth2/OIDC for secure API access
- Automatic Aggregation: Combines usage across different clusters and time periods
Configuration
Add the following configuration to your Waldur Site Agent offering:
offerings:
- name: "CSCS HPC Offering"
reporting_backend: "cscs-dwdi"
backend_settings:
cscs_dwdi_api_url: "https://dwdi-api.cscs.ch"
cscs_dwdi_client_id: "your-oidc-client-id"
cscs_dwdi_client_secret: "your-oidc-client-secret"
# Optional OIDC configuration (for production use)
cscs_dwdi_oidc_token_url: "https://identity.cscs.ch/realms/cscs/protocol/openid-connect/token"
cscs_dwdi_oidc_scope: "cscs-dwdi:read"
backend_components:
nodeHours:
measured_unit: "node-hours"
unit_factor: 1
accounting_type: "usage"
label: "Node Hours"
storage:
measured_unit: "TB"
unit_factor: 1
accounting_type: "usage"
label: "Storage Usage"
Configuration Parameters
Backend Settings
| Parameter | Required | Description |
|---|---|---|
cscs_dwdi_api_url |
Yes | Base URL for the CSCS-DWDI API service |
cscs_dwdi_client_id |
Yes | OIDC client ID for authentication |
cscs_dwdi_client_secret |
Yes | OIDC client secret for authentication |
cscs_dwdi_oidc_token_url |
Yes | OIDC token endpoint URL (required for authentication) |
cscs_dwdi_oidc_scope |
No | OIDC scope to request (defaults to "openid") |
Backend Components
Components must match the field names returned by the CSCS-DWDI API. For example:
nodeHours- Maps to thenodeHoursfield in API responsesstorage- Maps to thestoragefield in API responses (if available)gpuHours- Maps to thegpuHoursfield in API responses (if available)
Each component supports:
| Parameter | Description |
|---|---|
measured_unit |
Unit for display in Waldur (e.g., "node-hours", "TB") |
unit_factor |
Conversion factor from API units to measured units |
accounting_type |
Either "usage" for actual usage or "limit" for quotas |
label |
Display label in Waldur interface |
Usage Data Format
The plugin reports usage for all configured components:
- Component Types: Configurable (e.g.,
nodeHours,storage,gpuHours) - Units: Based on API response and
unit_factorconfiguration - Granularity: Monthly reporting with current month data
- User Attribution: Individual user usage within each account
- Aggregation: Automatically aggregates across clusters and time periods
API Integration
The plugin uses the CSCS-DWDI API endpoints:
GET /api/v1/compute/usage-month-multiaccount- Primary endpoint for monthly usage data- Authentication via OIDC Bearer tokens
Authentication
The plugin uses OAuth2/OIDC authentication with the following requirements:
- Requires
cscs_dwdi_oidc_token_urlin backend settings - Uses OAuth2
client_credentialsgrant flow - Automatically handles token caching and renewal
- Includes 5-minute safety margin for token expiry
- Fails with proper error logging if OIDC configuration is missing
Data Processing
- Account Filtering: Only reports on accounts that match Waldur resource backend IDs
- User Aggregation: Combines usage for the same user across different dates and clusters
- Time Range: Automatically queries from the first day of the current month to today
- Precision: Rounds node-hours to 2 decimal places
Installation
This plugin is part of the Waldur Site Agent workspace. To install:
# Install all workspace packages including cscs-dwdi plugin
uv sync --all-packages
# Install specific plugin for development
uv sync --extra cscs-dwdi
Testing
Run the plugin tests:
# Run CSCS-DWDI plugin tests
uv run pytest plugins/cscs-dwdi/tests/
# Run with coverage
uv run pytest plugins/cscs-dwdi/tests/ --cov=waldur_site_agent_cscs_dwdi
Limitations
This is a reporting-only backend that does not support:
- Account creation or deletion
- User management
- Resource limit management
- Order processing
- Membership synchronization
For these operations, use a different backend (e.g., SLURM) in combination with the CSCS-DWDI reporting backend:
offerings:
- name: "Mixed Backend Offering"
order_processing_backend: "slurm" # Use SLURM for orders
reporting_backend: "cscs-dwdi" # Use CSCS-DWDI for reporting
membership_sync_backend: "slurm" # Use SLURM for membership
Error Handling
The plugin includes comprehensive error handling:
- API Connectivity: Ping checks verify API availability
- Authentication: Token refresh and error handling
- Data Validation: Validates API responses and filters invalid data
- Retry Logic: Uses the framework's built-in retry mechanisms
Development
Project Structure
plugins/cscs-dwdi/
├── pyproject.toml # Plugin configuration
├── README.md # This documentation
├── waldur_site_agent_cscs_dwdi/
│ ├── __init__.py # Package init
│ ├── backend.py # Main backend implementation
│ └── client.py # CSCS-DWDI API client
└── tests/
└── test_cscs_dwdi.py # Plugin tests
Key Classes
CSCSDWDIBackend: Main backend class implementing reporting functionalityCSCSDWDIClient: HTTP client for CSCS-DWDI API communication
Extension Points
To extend the plugin:
- Additional Endpoints: Modify
CSCSDWDIClientto support more API endpoints - Authentication Methods: Update authentication logic in
client.py - Data Processing: Enhance
_process_api_response()for additional data formats
Troubleshooting
Common Issues
Authentication Failures
- Verify OIDC client credentials
- Check API URL configuration
- Ensure proper token scopes
Missing Usage Data
- Verify account names match between Waldur and CSCS-DWDI
- Check date ranges and API response format
- Review API rate limits and quotas
Network Connectivity
- Test API connectivity with ping functionality
- Verify network access from agent deployment environment
- Check firewall and proxy settings
Debugging
Enable debug logging for detailed API interactions:
import logging
logging.getLogger('waldur_site_agent_cscs_dwdi').setLevel(logging.DEBUG)
Support
For issues and questions:
- Check the Waldur Site Agent documentation
- Review plugin test cases for usage examples
- Create issues in the project repository
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file waldur_site_agent_cscs_dwdi-0.7.0.tar.gz.
File metadata
- Download URL: waldur_site_agent_cscs_dwdi-0.7.0.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5085d5167c28b4ce9aff9b6ba1d7923eef9aa8a35656f2c33a669905cb834c0d
|
|
| MD5 |
76ab9c372ebed62e7f6baaa372687deb
|
|
| BLAKE2b-256 |
a1c5a0edfacf30380b4b6fea926c37fc12b81073abf495313407da0a3faf0959
|
File details
Details for the file waldur_site_agent_cscs_dwdi-0.7.0-py3-none-any.whl.
File metadata
- Download URL: waldur_site_agent_cscs_dwdi-0.7.0-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c940092d2a3ad7e334ae5ed872a4637d395a71befcc00a526f009ec12667b2d1
|
|
| MD5 |
c1ba549276a4473f6b580ce0477081eb
|
|
| BLAKE2b-256 |
5fdb7bb42c7f8556911ab2a5844c66f83d4f7ded5bf23b41f39c87cc08c7a519
|