Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Refactors zone data transformation to CAMARA format#151

Merged
adrian-pino merged 1 commit intomainfrom
fix/review-comments-i2edge-150
Jul 30, 2025
Merged

Refactors zone data transformation to CAMARA format#151
adrian-pino merged 1 commit intomainfrom
fix/review-comments-i2edge-150

Conversation

@adrian-pino
Copy link
Copy Markdown
Collaborator

  • 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.
@adrian-pino adrian-pino merged commit 8c354f9 into main Jul 30, 2025
2 checks passed
@adrian-pino adrian-pino deleted the fix/review-comments-i2edge-150 branch July 30, 2025 10:36
@adrian-pino adrian-pino requested a review from Copilot July 30, 2025 12:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines +53 to +60
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")
Copy link

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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"

Copilot uses AI. Check for mistakes.
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()]
Copy link

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
[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()]

Copilot uses AI. Check for mistakes.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants