fix: align datacenter enum with valid real-world targets#336
Conversation
|
Promptless prepared a documentation update related to this change. Triggered by runpod/flash PR #336 Updated datacenter reference tables and code examples to reflect the removal of four datacenters that lack storage + S3 support ( |
There was a problem hiding this comment.
Pull request overview
This PR narrows the DataCenter enum to supported storage/S3 locations, moves it into a dedicated resource module, and updates related imports/tests.
Changes:
- Adds
core/resources/datacenter.pyforDataCenterandCPU_DATACENTERS. - Updates resource imports to use the new datacenter module.
- Refreshes tests to use supported datacenter values and validate new endpoint defaults.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/runpod_flash/core/resources/datacenter.py |
Defines the moved/pruned datacenter enum and CPU datacenter set. |
src/runpod_flash/core/resources/network_volume.py |
Imports DataCenter from the new module. |
src/runpod_flash/core/resources/serverless.py |
Imports datacenter symbols from the new module. |
src/runpod_flash/core/resources/__init__.py |
Re-exports datacenter symbols from the new module. |
src/runpod_flash/endpoint.py |
Adds default datacenter selection for non-CPU endpoint configs. |
tests/unit/test_endpoint.py |
Updates datacenter imports/values and endpoint default tests. |
tests/unit/test_p2_gaps.py |
Updates datacenter import path. |
tests/unit/runtime/test_resource_provisioner.py |
Updates expected supported datacenter values. |
tests/unit/resources/test_serverless.py |
Updates serverless datacenter tests to supported values. |
tests/unit/resources/test_network_volume.py |
Updates datacenter import path. |
tests/unit/cli/commands/build_utils/test_manifest.py |
Updates manifest fixture imports and datacenter values. |
Comments suppressed due to low confidence (1)
src/runpod_flash/endpoint.py:420
- Using a truthiness check here treats explicit falsy values (for example
datacenter=""ordatacenter=[]) the same as an omitted datacenter and silently replaces them with all datacenters. Those inputs would otherwise be rejected or preserved by downstream validation, so this can mask bad configuration instead of surfacing an error; check specifically forNonewhen applying the default.
if not self._is_cpu and not self.is_client and not self.datacenter:
self.datacenter = DataCenter.all()
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if not self._is_cpu and not self.is_client and not self.datacenter: | ||
| self.datacenter = DataCenter.all() |
| class DataCenter(str, Enum): | ||
| """Enum representing available RunPod data centers. | ||
|
|
||
| NOTE: these are only datacenters with storage support, and s3 API support. |
| field_serializer, | ||
| model_validator, | ||
| ) | ||
| from .datacenter import DataCenter |
deanq
left a comment
There was a problem hiding this comment.
Coverage gap — suggest new test file
DataCenter.from_string and DataCenter.all() aren't directly tested. Suggest adding tests/unit/resources/test_datacenter.py:
from_stringhappy path (canonical, lowercase, underscore-separated)from_stringerror path (verify message includes valid list)all()returns expected 11 membersCPU_DATACENTERS == {DataCenter.EU_RO_1}(catches silent expansion)
Stale fixtures — tests/unit/resources/test_worker_availability_diagnostic.py
Still has literal "US-GA-2" string fixtures at lines 35, 51, 59, 76, 84, 100. They pass because they're strings, not enum refs, but they advertise a DC that no longer exists. Worth migrating to "US-CA-2" for consistency.
serverless.py:580 — silent fallback for unknown DC
With the enum shrunk, the except ValueError branch at src/runpod_flash/core/resources/serverless.py:582-583 now also triggers for legitimate platform DCs that the SDK simply doesn't know about yet — indistinguishable from a typo'd env var. Suggest:
except ValueError:
log.warning(
"RUNPOD_DEFAULT_DATACENTER=%r is not in the known DataCenter enum; "
"passing through as raw string. SDK may be stale.",
env_datacenter,
)
self.locations = env_datacenter
removes data centers from the
DataCenterenum that dont have both storage and s3 support. This should prevent the uncaught "no primary storage mount" error during worker initialization.Also moves the
DataCenterenum out ofnetwork_volume.pyintodatacenter.py.