Refactors zone data transformation to CAMARA format#151
Conversation
adrian-pino
commented
Jul 30, 2025
- Introduces a dedicated function to transform i2Edge zone data into the CAMARA EdgeCloudZone format, improving code readability and maintainability.
- Improves error handling for invalid CAMARA manifests by providing more detailed information about validation failures.
- Increases the wait time in the end-to-end tests to avoid potential timing issues.
Introduces a dedicated function to transform i2Edge zone data into the CAMARA EdgeCloudZone format, improving code readability and maintainability. Improves error handling for invalid CAMARA manifests by providing more detailed information about validation failures. Increases the wait time in the end-to-end tests to avoid potential timing issues.
There was a problem hiding this comment.
Pull Request Overview
This PR refactors zone data transformation in the i2Edge client adapter by extracting transformation logic into a dedicated method, improving error handling for CAMARA manifest validation with more detailed error messages, and increasing wait time in end-to-end tests from 10 to 30 seconds to avoid timing issues.
- Introduces
_transform_to_camara_zone()method to encapsulate zone data transformation logic - Enhances error handling for ValidationError exceptions with detailed field-specific error information
- Increases test wait time from 10 to 30 seconds in end-to-end tests
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/sunrise6g_opensdk/edgecloud/adapters/i2edge/client.py | Refactors zone transformation into dedicated method and improves CAMARA manifest validation error handling |
| tests/edgecloud/test_e2e.py | Increases timer wait duration from 10 to 30 seconds |
| return camara_schemas.EdgeCloudZone( | ||
| edgeCloudZoneId=camara_schemas.EdgeCloudZoneId(zone_data.get("zoneId", "unknown")), | ||
| edgeCloudZoneName=camara_schemas.EdgeCloudZoneName( | ||
| zone_data.get("nodeName", "unknown") | ||
| ), | ||
| edgeCloudProvider=camara_schemas.EdgeCloudProvider("i2edge"), | ||
| edgeCloudRegion=camara_schemas.EdgeCloudRegion( | ||
| zone_data.get("geographyDetails", "unknown") |
There was a problem hiding this comment.
Using 'unknown' as a fallback value for missing zone data may mask data quality issues. Consider logging a warning when fallback values are used or throwing an exception for required fields that are missing.
| return camara_schemas.EdgeCloudZone( | |
| edgeCloudZoneId=camara_schemas.EdgeCloudZoneId(zone_data.get("zoneId", "unknown")), | |
| edgeCloudZoneName=camara_schemas.EdgeCloudZoneName( | |
| zone_data.get("nodeName", "unknown") | |
| ), | |
| edgeCloudProvider=camara_schemas.EdgeCloudProvider("i2edge"), | |
| edgeCloudRegion=camara_schemas.EdgeCloudRegion( | |
| zone_data.get("geographyDetails", "unknown") | |
| zone_id = zone_data.get("zoneId") | |
| if not zone_id: | |
| log.warning("Missing 'zoneId' in zone_data. Using fallback value 'unknown'.") | |
| node_name = zone_data.get("nodeName") | |
| if not node_name: | |
| log.warning("Missing 'nodeName' in zone_data. Using fallback value 'unknown'.") | |
| geography_details = zone_data.get("geographyDetails") | |
| if not geography_details: | |
| log.warning("Missing 'geographyDetails' in zone_data. Using fallback value 'unknown'.") | |
| return camara_schemas.EdgeCloudZone( | |
| edgeCloudZoneId=camara_schemas.EdgeCloudZoneId(zone_id or "unknown"), | |
| edgeCloudZoneName=camara_schemas.EdgeCloudZoneName( | |
| node_name or "unknown" | |
| ), | |
| edgeCloudProvider=camara_schemas.EdgeCloudProvider("i2edge"), | |
| edgeCloudRegion=camara_schemas.EdgeCloudRegion( | |
| geography_details or "unknown" |
| log.error(f"Invalid CAMARA manifest: {e}") | ||
| raise ValueError(f"Invalid CAMARA manifest: {e}") | ||
| error_details = "; ".join( | ||
| [f"Field '{err['loc'][0]}': {err['msg']}" for err in e.errors()] |
There was a problem hiding this comment.
Accessing err['loc'][0] without checking if the location tuple is non-empty could cause an IndexError if ValidationError contains errors with empty location paths.
| [f"Field '{err['loc'][0]}': {err['msg']}" for err in e.errors()] | |
| [f"Field '{err['loc'][0] if err['loc'] else 'unknown field'}': {err['msg']}" for err in e.errors()] |