Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions docs/Flash_Deploy_Guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,14 @@ result = await vllm.post("/v1/completions", {"prompt": "hello"})
### Persistent Storage

```python
from runpod_flash import Endpoint, GpuGroup, NetworkVolume
from runpod_flash import Endpoint, GpuGroup, DataCenter, NetworkVolume, PodTemplate

vol = NetworkVolume(id="vol_abc123")
vol = NetworkVolume(name="model-cache", size=100, datacenter=DataCenter.US_GA_1)

@Endpoint(
name="model-server",
gpu=GpuGroup.AMPERE_80,
datacenter=DataCenter.US_GA_1,
volume=vol,
template=PodTemplate(containerDiskInGb=100),
)
Expand All @@ -304,6 +305,24 @@ async def serve(data: dict) -> dict:
...
```

Multiple volumes across datacenters:

```python
volumes = [
NetworkVolume(name="models-us", size=100, datacenter=DataCenter.US_GA_1),
NetworkVolume(name="models-eu", size=100, datacenter=DataCenter.EU_RO_1),
]

@Endpoint(
name="global-server",
gpu=GpuGroup.AMPERE_80,
datacenter=[DataCenter.US_GA_1, DataCenter.EU_RO_1],
volume=volumes,
)
async def serve(data: dict) -> dict:
...
```

## Troubleshooting

### Build Issues
Expand Down
39 changes: 31 additions & 8 deletions docs/Flash_SDK_Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Endpoint(
dependencies: Optional[List[str]] = None,
system_dependencies: Optional[List[str]] = None,
accelerate_downloads: bool = True,
volume: Optional[NetworkVolume] = None,
datacenter: DataCenter = DataCenter.EU_RO_1,
volume: Optional[Union[NetworkVolume, List[NetworkVolume]]] = None,
datacenter: Optional[Union[DataCenter, List[DataCenter], str, List[str]]] = None,
env: Optional[Dict[str, str]] = None,
gpu_count: int = 1,
execution_timeout_ms: int = 0,
Expand All @@ -46,8 +46,8 @@ Endpoint(
| `dependencies` | `list[str]` | `None` | Python packages to install (e.g., `["torch", "numpy==1.24"]`). |
| `system_dependencies` | `list[str]` | `None` | System packages to install. |
| `accelerate_downloads` | `bool` | `True` | Enable accelerated downloads. |
| `volume` | `NetworkVolume` | `None` | Network volume for persistent storage. |
| `datacenter` | `DataCenter` | `EU_RO_1` | Preferred datacenter. |
| `volume` | `NetworkVolume` or list | `None` | Network volume(s) for persistent storage. One volume per datacenter. |
| `datacenter` | `DataCenter`, list, `str`, or `None` | `None` | Datacenter(s) to deploy into. `None` means all available DCs. Accepts a single value, a list, or string DC IDs. CPU endpoints must use DCs in `CPU_DATACENTERS`. |
| `env` | `dict[str, str]` | `None` | Environment variables for the endpoint. |
| `gpu_count` | `int` | `1` | GPUs per worker. |
| `execution_timeout_ms` | `int` | `0` | Max execution time in ms. 0 = no limit. |
Expand Down Expand Up @@ -335,8 +335,20 @@ CPU instance selection. Can also be passed as a string to `cpu=`.

| Value | Location |
|-------|----------|
| `DataCenter.EU_RO_1` | Europe - Romania (default) |
| `DataCenter.US_TX_3` | US - Texas |
| `DataCenter.US_GA_1` | US - Georgia |
| `DataCenter.US_KS_1` | US - Kansas |
| `DataCenter.US_TX_1` | US - Texas |
| `DataCenter.US_OR_1` | US - Oregon |
| `DataCenter.CA_MTL_1` | Canada - Montreal |
| `DataCenter.EU_NL_1` | Europe - Netherlands |
| `DataCenter.EU_CZ_1` | Europe - Czech Republic |
| `DataCenter.EU_RO_1` | Europe - Romania |
| `DataCenter.EU_NO_1` | Europe - Norway |
| `DataCenter.EU_SE_1` | Europe - Sweden |

When `datacenter=None` (the default), the endpoint is available in all data centers.

CPU endpoints are restricted to the `CPU_DATACENTERS` subset: `EU_RO_1`, `US_TX_1`, `EU_SE_1`.

### CudaVersion

Expand All @@ -350,12 +362,22 @@ CPU instance selection. Can also be passed as a string to `cpu=`.

### NetworkVolume

Persistent storage that survives worker restarts.
Persistent storage that survives worker restarts. Each volume is tied to a specific datacenter.

```python
from runpod_flash import NetworkVolume
from runpod_flash import NetworkVolume, DataCenter

# existing volume by ID
vol = NetworkVolume(id="vol_abc123")
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

The docs show vol = NetworkVolume(id="vol_abc123"), but NetworkVolume currently requires a name field (no default) in the model. Either update the example to include name=... when referencing an existing volume, or make name optional when id is provided.

Suggested change
vol = NetworkVolume(id="vol_abc123")
vol = NetworkVolume(id="vol_abc123", name="my-existing-volume")

Copilot uses AI. Check for mistakes.

# create a new volume in a specific datacenter
vol = NetworkVolume(name="my-models", size=100, datacenter=DataCenter.US_GA_1)

# multiple volumes across datacenters (one per DC)
volumes = [
NetworkVolume(name="models-us", size=100, datacenter=DataCenter.US_GA_1),
NetworkVolume(name="models-eu", size=100, datacenter=DataCenter.EU_RO_1),
]
```

### PodTemplate
Expand Down Expand Up @@ -392,6 +414,7 @@ from runpod_flash import (
CpuInstanceType,
CudaVersion,
DataCenter,
CPU_DATACENTERS,
NetworkVolume,
PodTemplate,
ServerlessScalerType,
Expand Down
5 changes: 5 additions & 0 deletions src/runpod_flash/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from .client import remote
from .endpoint import Endpoint, EndpointJob
from .core.resources import (
CPU_DATACENTERS,
CpuInstanceType,
CpuLiveLoadBalancer,
CpuLiveServerless,
Expand Down Expand Up @@ -58,6 +59,7 @@

_RESOURCE_NAMES = frozenset(
{
"CPU_DATACENTERS",
"CpuInstanceType",
"CpuLiveLoadBalancer",
"CpuLiveServerless",
Expand Down Expand Up @@ -104,6 +106,7 @@ def __getattr__(name):
return remote
elif name in _RESOURCE_NAMES:
from .core.resources import (
CPU_DATACENTERS,
CpuInstanceType,
CpuLiveLoadBalancer,
CpuLiveServerless,
Expand All @@ -126,6 +129,7 @@ def __getattr__(name):
)

attrs = {
"CPU_DATACENTERS": CPU_DATACENTERS,
"CpuInstanceType": CpuInstanceType,
"CpuLiveLoadBalancer": CpuLiveLoadBalancer,
"CpuLiveServerless": CpuLiveServerless,
Expand Down Expand Up @@ -173,6 +177,7 @@ def __getattr__(name):
"Endpoint",
"EndpointJob",
"remote",
"CPU_DATACENTERS",
"CpuInstanceType",
"CpuLiveLoadBalancer",
"CpuLiveServerless",
Expand Down
3 changes: 3 additions & 0 deletions src/runpod_flash/cli/commands/build_utils/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ def _extract_config_properties(config: Dict[str, Any], resource_config) -> None:
):
config["scalerValue"] = resource_config.scalerValue

if hasattr(resource_config, "locations") and resource_config.locations:
config["locations"] = resource_config.locations

if hasattr(resource_config, "env") and resource_config.env:
env_dict = dict(resource_config.env)
env_dict.pop("RUNPOD_API_KEY", None)
Expand Down
4 changes: 4 additions & 0 deletions src/runpod_flash/core/api/runpod.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@ async def save_endpoint(self, input_data: Dict[str, Any]) -> Dict[str, Any]:
locations
name
networkVolumeId
networkVolumeIds {
networkVolumeId
dataCenterId
}
flashEnvironmentId
scalerType
scalerValue
Expand Down
3 changes: 2 additions & 1 deletion src/runpod_flash/core/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
)
from .serverless_cpu import CpuServerlessEndpoint
from .template import PodTemplate
from .network_volume import NetworkVolume, DataCenter
from .network_volume import NetworkVolume, DataCenter, CPU_DATACENTERS
from .load_balancer_sls_resource import (
CpuLoadBalancerSlsResource,
LoadBalancerSlsResource,
Expand All @@ -33,6 +33,7 @@
"CpuLoadBalancerSlsResource",
"CpuServerlessEndpoint",
"CudaVersion",
"CPU_DATACENTERS",
"DataCenter",
"DeployableResource",
"GpuGroup",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ class CpuLoadBalancerSlsResource(CpuEndpointMixin, LoadBalancerSlsResource):
"allowedCudaVersions",
"imageName",
"networkVolume",
"networkVolumes",
"python_version",
}

Expand Down
58 changes: 51 additions & 7 deletions src/runpod_flash/core/resources/network_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from pydantic import (
Field,
field_serializer,
model_validator,
)

from ..api.runpod import RunpodRestClient
Expand All @@ -17,12 +18,44 @@


class DataCenter(str, Enum):
"""
Enum representing available data centers for network volumes.
#TODO: Add more data centers as needed. Lock this to the available data center.
"""

"""Enum representing available RunPod data centers."""

US_GA_1 = "US-GA-1"
US_KS_1 = "US-KS-1"
US_TX_1 = "US-TX-1"
US_OR_1 = "US-OR-1"
CA_MTL_1 = "CA-MTL-1"
EU_NL_1 = "EU-NL-1"
EU_CZ_1 = "EU-CZ-1"
EU_RO_1 = "EU-RO-1"
EU_NO_1 = "EU-NO-1"
EU_SE_1 = "EU-SE-1"

@classmethod
def from_string(cls, value: str) -> "DataCenter":
"""Parse a datacenter ID string into a DataCenter enum.

Accepts the canonical form (e.g. "EU-RO-1") as well as common
variations like lowercase or underscore-separated.
"""
normalized = value.strip().upper().replace("_", "-")
try:
return cls(normalized)
except ValueError:
valid = ", ".join(dc.value for dc in cls)
raise ValueError(
f"Unknown datacenter '{value}'. Valid datacenters: {valid}"
)


# data centers that support CPU serverless endpoints
CPU_DATACENTERS: frozenset[DataCenter] = frozenset(
{
DataCenter.EU_RO_1,
DataCenter.US_TX_1,
DataCenter.EU_SE_1,
}
)


class NetworkVolume(DeployableResource):
Expand All @@ -41,13 +74,24 @@ class NetworkVolume(DeployableResource):
"name",
}

# Internal fixed value
dataCenterId: DataCenter = Field(default=DataCenter.EU_RO_1, frozen=True)
# public alias -- users pass datacenter=, which syncs to dataCenterId for the API
datacenter: Optional[DataCenter] = Field(default=None, exclude=True)
dataCenterId: DataCenter = Field(default=DataCenter.EU_RO_1)

id: Optional[str] = Field(default=None)
name: str
size: Optional[int] = Field(default=100, gt=0) # Size in GB

@model_validator(mode="before")
@classmethod
def sync_datacenter_alias(cls, data):
"""Allow datacenter= as a user-friendly alias for dataCenterId."""
if isinstance(data, dict):
dc = data.pop("datacenter", None)
if dc is not None and "dataCenterId" not in data:
data["dataCenterId"] = dc
return data

def __str__(self) -> str:
return f"{self.__class__.__name__}:{self.id}"

Expand Down
Loading
Loading