Overview
The Resource Service uses AI (Google Gemini) to automatically generate Python wrappers that fetch, transform, and send sustainability indicator data. Wrappers support multiple data sources including CSV files, Excel spreadsheets, and REST APIs.Data Source Types
The system supports three source types:CSV
Comma-separated value files with time-series data
XLSX
Excel workbooks (both .xlsx and .xls formats)
API
REST APIs with JSON responses
Generating a CSV Wrapper
Generate a wrapper from an uploaded CSV file:Upload the CSV File
First, upload your CSV file to get a Save the returned
file_id:file_id for the next step.The backend automatically resolves the
file_id to the internal file path, so you don’t need to provide the location field.Generating an XLSX Wrapper
Excel files work similarly to CSV files:Generating an API Wrapper
Create a wrapper that polls a REST API for real-time data:API Authentication Types
The system supports multiple authentication methods:- Bearer Token
- API Key
- Basic Auth
- No Auth
Response Structure
Successful Generation Response:Wrapper Generation Workflow
AI Code Generation
Status changes to
generating. The AI generates Python code based on the source type and metadata.Code Saved
Generated code is saved to
/app/generated_wrappers/{wrapper_id}.py and stored in the database.Execution Started
Status changes to
executing. The wrapper process is started in a separate Python process.Wrapper Statuses
| Status | Description |
|---|---|
pending | Wrapper created, waiting for generation |
generating | AI is generating the wrapper code |
creating_resource | Resource is being created |
executing | Wrapper is running and collecting data |
completed | Wrapper finished successfully (file-based only) |
stopped | Wrapper was manually stopped |
error | Wrapper encountered an error |
Metadata Fields
All wrappers require comprehensive metadata:Clear, descriptive name for the indicator
High-level domain (e.g., “Environment”, “Social”, “Economic”)
Specific subdomain (e.g., “Climate Change”, “Air Quality”, “Energy”)
Detailed description of what the indicator measures
Unit of measurement (e.g., “tons CO2”, “AQI”, “percentage”)
Name of the data source or organization
Geographic or organizational scale (e.g., “National”, “Regional”, “Local”)
Whether this is a governance indicator
Maximum sustainable capacity (optional)
Data collection frequency (e.g., “annual”, “monthly”, “real-time”)
Error Handling
Common Errors
File not found (400)
File not found (400)
Error:Solution: Verify the file_id exists by checking
/api/v1/files/{file_id} or uploading the file again.Invalid request (400)
Invalid request (400)
Error:Solution: Ensure all required metadata fields are provided and properly formatted.
Service unavailable (503)
Service unavailable (503)
Best Practices
Validate Files First
Upload and validate your CSV/XLSX files before generating wrappers to catch data issues early.
Use Descriptive Metadata
Provide detailed, accurate metadata to help the AI generate better wrapper code.
Test API Endpoints
Verify API endpoints are accessible and return expected data before generating wrappers.
Monitor Generation
Check wrapper status regularly during generation to catch errors quickly.
Next Steps
File Upload
Learn how to upload and validate CSV/XLSX files
Wrapper Execution
Understand how wrappers execute and collect data
Monitoring
Monitor wrapper health and view execution logs
API Reference
View complete API documentation