Skip to content

Commit 1eff33e

Browse files
committed
refactor: update the dockerfile and handler
Signed-off-by: pandyamarut <[email protected]>
1 parent 008bd90 commit 1eff33e

File tree

6 files changed

+63
-71
lines changed

6 files changed

+63
-71
lines changed

Dockerfile-runtime-two renamed to Dockerfile-load-balancer-sls

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Runtime Two Dockerfile - Dual-capability serverless runtime
1+
# Load Balancer SLS Dockerfile - Dual-capability serverless runtime
22
# Supports both remote execution and HTTP endpoints
33

44
# Use Python 3.11 base image with CUDA support
@@ -28,7 +28,7 @@ RUN uv sync --frozen
2828
# Set Python path
2929
ENV PYTHONPATH="/app/src:$PYTHONPATH"
3030

31-
# Environment variables for Runtime Two
31+
# Environment variables for Load Balancer SLS
3232
ENV RUNTIME_MODE="dual"
3333
ENV ENABLE_HTTP_SERVER="true"
3434
ENV ENABLE_REMOTE_EXECUTION="true"
@@ -42,4 +42,4 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
4242
CMD curl -f http://localhost:8000/health || exit 1
4343

4444
# Default command - can run in both serverless and HTTP modes
45-
CMD ["uv", "run", "python", "src/runtime_two_handler.py"]
45+
CMD ["uv", "run", "python", "src/load_balancer_sls_handler.py"]

Makefile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
IMAGE = runpod/tetra-rp
2-
RUNTIME_TWO_IMAGE = mwiki/worker-tetra-runtime-two
2+
LOAD_BALANCER_SLS_IMAGE = mwiki/worker-tetra-load-balancer-sls
33
TAG = local
44
FULL_IMAGE = $(IMAGE):$(TAG)
55
FULL_IMAGE_CPU = $(IMAGE)-cpu:$(TAG)
6-
FULL_IMAGE_RUNTIME_TWO = $(RUNTIME_TWO_IMAGE):$(TAG)
6+
FULL_IMAGE_LOAD_BALANCER_SLS = $(LOAD_BALANCER_SLS_IMAGE):$(TAG)
77

88
.PHONY: setup help
99

@@ -36,10 +36,10 @@ setup: dev # Initialize project, sync deps, update submodules
3636
git submodule update --remote --merge
3737
cp tetra-rp/src/tetra_rp/protos/remote_execution.py src/
3838

39-
build: # Build all Docker images (GPU, CPU, Runtime Two)
39+
build: # Build all Docker images (GPU, CPU, Load Balancer SLS)
4040
make build-gpu
4141
make build-cpu
42-
make build-runtime-two
42+
make build-load-balancer-sls
4343

4444
build-gpu: setup # Build GPU Docker image (linux/amd64)
4545
docker buildx build \
@@ -54,11 +54,11 @@ build-cpu: setup # Build CPU-only Docker image (linux/amd64)
5454
-t $(FULL_IMAGE_CPU) \
5555
. --load
5656

57-
build-runtime-two: setup # Build Runtime Two dual-capability image (linux/amd64)
57+
build-load-balancer-sls: setup # Build Load Balancer SLS dual-capability image (linux/amd64)
5858
docker buildx build \
5959
--platform linux/amd64 \
60-
-f Dockerfile-runtime-two \
61-
-t $(FULL_IMAGE_RUNTIME_TWO) \
60+
-f Dockerfile-load-balancer-sls \
61+
-t $(FULL_IMAGE_LOAD_BALANCER_SLS) \
6262
. --load
6363

6464
# Test commands
@@ -80,8 +80,8 @@ test-fast: # Run tests with fast-fail mode
8080
test-handler: # Test handler locally with all test_*.json files
8181
cd src && ./test-handler.sh
8282

83-
test-runtime-two: build-runtime-two # Test Runtime Two container locally
84-
docker run --rm -p 8000:8000 $(FULL_IMAGE_RUNTIME_TWO)
83+
test-load-balancer-sls: build-load-balancer-sls # Test Load Balancer SLS container locally
84+
docker run --rm -p 8000:8000 $(FULL_IMAGE_LOAD_BALANCER_SLS)
8585

8686
# Smoke Tests (local on Mac OS)
8787

pyproject.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,11 @@ dependencies = [
99
"pydantic>=2.11.4",
1010
"requests>=2.25.0",
1111
"runpod",
12-
<<<<<<< HEAD
1312
"fastapi>=0.104.0",
1413
"uvicorn[standard]>=0.24.0",
1514
"aiohttp>=3.9.0",
16-
=======
1715
"hf_transfer>=0.1.0",
1816
"huggingface_hub>=0.32.0",
19-
>>>>>>> main
2017
]
2118

2219
[dependency-groups]

src/runtime_two_handler.py renamed to src/load_balancer_sls_handler.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
2-
Runtime Two Handler - Dual-capability serverless runtime
2+
Load Balancer SLS Handler - Dual-capability serverless runtime
33
4-
This module implements the main server for Runtime Two that supports both:
4+
This module implements the main server for Load Balancer SLS that supports both:
55
1. Traditional remote execution (via RemoteExecutor)
66
2. HTTP endpoint exposure (via FastAPI)
77
"""
@@ -23,23 +23,23 @@
2323
log = logging.getLogger(__name__)
2424

2525

26-
class RuntimeTwoServer:
26+
class LoadBalancerSlsServer:
2727
"""
28-
Runtime Two server that provides dual execution capabilities:
28+
Load Balancer SLS server that provides dual execution capabilities:
2929
- Remote execution for programmatic calls
3030
- HTTP endpoints for decorated methods
3131
"""
3232

3333
def __init__(self):
3434
self.remote_executor = RemoteExecutor()
3535
self.class_registry = ClassRegistry()
36-
self.app = FastAPI(title="Runtime Two Server", version="1.0.0")
36+
self.app = FastAPI(title="Load Balancer SLS Server", version="1.0.0")
3737
self.port = int(os.environ.get("PORT", 8000))
3838

3939
# Setup routes
4040
self._setup_routes()
4141

42-
log.info("Runtime Two server initialized")
42+
log.info("Load Balancer SLS server initialized")
4343

4444
def _setup_routes(self):
4545
"""Setup FastAPI routes for HTTP endpoints."""
@@ -49,7 +49,7 @@ def _setup_routes(self):
4949
async def health_check():
5050
return {
5151
"status": "healthy",
52-
"runtime": "two",
52+
"runtime": "load_balancer_sls",
5353
"capabilities": ["remote_execution", "http_endpoints"],
5454
}
5555

@@ -113,7 +113,8 @@ async def remote_execution(request: Request):
113113
except Exception as e:
114114
log.error(f"Remote execution error: {e}")
115115
error_response = FunctionResponse(
116-
success=False, error=f"Runtime Two remote execution error: {str(e)}"
116+
success=False,
117+
error=f"Load Balancer SLS remote execution error: {str(e)}",
117118
)
118119
return error_response.model_dump()
119120

@@ -241,8 +242,8 @@ async def _install_dependencies(self, request: FunctionRequest) -> FunctionRespo
241242
)
242243

243244
async def start_server(self):
244-
"""Start the Runtime Two server."""
245-
log.info(f"Starting Runtime Two server on port {self.port}")
245+
"""Start the Load Balancer SLS server."""
246+
log.info(f"Starting Load Balancer SLS server on port {self.port}")
246247

247248
# Run FastAPI with uvicorn
248249
config = uvicorn.Config(
@@ -253,18 +254,18 @@ async def start_server(self):
253254

254255

255256
# Singleton server instance
256-
_server_instance: Optional[RuntimeTwoServer] = None
257+
_server_instance: Optional[LoadBalancerSlsServer] = None
257258

258259

259-
def get_server() -> RuntimeTwoServer:
260-
"""Get or create the Runtime Two server instance."""
260+
def get_server() -> LoadBalancerSlsServer:
261+
"""Get or create the Load Balancer SLS server instance."""
261262
global _server_instance
262263
if _server_instance is None:
263-
_server_instance = RuntimeTwoServer()
264+
_server_instance = LoadBalancerSlsServer()
264265
return _server_instance
265266

266267

267-
# Runtime Two runs as pure FastAPI server - no traditional handler function needed
268+
# Load Balancer SLS runs as pure FastAPI server - no traditional handler function needed
268269

269270

270271
# For standalone HTTP server mode
@@ -277,4 +278,4 @@ def get_server() -> RuntimeTwoServer:
277278
server = get_server()
278279
asyncio.run(server.start_server())
279280
else:
280-
log.info("Runtime Two handler ready for serverless execution")
281+
log.info("Load Balancer SLS handler ready for serverless execution")

0 commit comments

Comments
 (0)