|
17 | 17 | from base64 import b64encode |
18 | 18 | from enum import IntEnum |
19 | 19 | from ipaddress import IPv4Address, IPv6Address, ip_address |
20 | | -from typing import Literal, Self |
| 20 | +from typing import Any, Literal, Self |
21 | 21 |
|
22 | 22 | import aiohttp |
23 | 23 | from aiohttp import web |
@@ -115,6 +115,7 @@ class CreateExAppPayload(ExAppName): |
115 | 115 | "cpu", description="Possible values: 'cpu', 'rocm' or 'cuda'" |
116 | 116 | ) |
117 | 117 | mount_points: list[CreateExAppMounts] = Field([], description="List of mount points for the container.") |
| 118 | + resource_limits: dict[str, Any] = Field({}, description="Resource limits for the container.") |
118 | 119 |
|
119 | 120 |
|
120 | 121 | class RemoveExAppPayload(ExAppName): |
@@ -649,6 +650,12 @@ async def docker_exapp_create(request: web.Request): |
649 | 650 | devices.append({"PathOnHost": device, "PathInContainer": device, "CgroupPermissions": "rwm"}) |
650 | 651 | container_config["HostConfig"]["Devices"] = devices |
651 | 652 |
|
| 653 | + if payload.resource_limits: |
| 654 | + if "memory" in payload.resource_limits: |
| 655 | + container_config["HostConfig"]["Memory"] = payload.resource_limits["memory"] |
| 656 | + if "nanoCPUs" in payload.resource_limits: |
| 657 | + container_config["HostConfig"]["NanoCPUs"] = payload.resource_limits["nanoCPUs"] |
| 658 | + |
652 | 659 | for extra_mount in payload.mount_points: |
653 | 660 | container_config["HostConfig"]["Mounts"].append( |
654 | 661 | { |
|
0 commit comments