Skip to content

Commit

Permalink
Revert endpoint change (#796)
Browse files Browse the repository at this point in the history
Temporarily reverting the endpoint status change so that we can give
users a longer warning period before making this change.
  • Loading branch information
dleviminzi authored Dec 18, 2024
1 parent 7da5257 commit c515d8c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion sdk/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "beta9"
version = "0.1.138"
version = "0.1.139"
description = ""
authors = ["beam.cloud <[email protected]>"]
packages = [
Expand Down
16 changes: 10 additions & 6 deletions sdk/src/beta9/runner/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import traceback
from contextlib import asynccontextmanager
from http import HTTPStatus
from typing import Any, Dict, Optional, Union
from typing import Any, Dict, Optional, Tuple, Union

from fastapi import Depends, FastAPI, Request
from fastapi.responses import JSONResponse, Response
Expand Down Expand Up @@ -197,10 +197,13 @@ async def function(
payload = await request.json()

status_code = HTTPStatus.OK
task_lifecycle_data.result = await self._call_function(task_id=task_id, payload=payload)

if task_lifecycle_data.result.get("error"):
task_lifecycle_data.result, err = await self._call_function(
task_id=task_id, payload=payload
)
if err:
task_lifecycle_data.status = TaskStatus.Error

if task_lifecycle_data.status == TaskStatus.Error:
status_code = HTTPStatus.INTERNAL_SERVER_ERROR

kwargs = payload.get("kwargs", {})
Expand All @@ -222,7 +225,8 @@ def _create_response(self, *, body: Any, status_code: int = HTTPStatus.OK) -> Re
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
)

async def _call_function(self, task_id: str, payload: dict) -> Response:
async def _call_function(self, task_id: str, payload: dict) -> Tuple[Response, Any]:
error = None
response_body = {}

args = payload.get("args", [])
Expand Down Expand Up @@ -257,7 +261,7 @@ async def _call_function(self, task_id: str, payload: dict) -> Response:
print(exception)
response_body = {"error": exception}

return response_body
return response_body, error

def shutdown(self, signum=None, frame=None):
os._exit(self.exit_code)
Expand Down

0 comments on commit c515d8c

Please sign in to comment.