Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(BA-469): Rename variables api_rqst to api_request for clarity #3404

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
4 changes: 2 additions & 2 deletions src/ai/backend/client/cli/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ async def run(self) -> None:
if len(self.envs.keys()) > 0:
params["envs"] = json.dumps(self.envs)

api_rqst = Request("GET", path, b"", params=params, content_type="application/json")
async with api_rqst.connect_websocket() as ws:
api_request = Request("GET", path, b"", params=params, content_type="application/json")
async with api_request.connect_websocket() as ws:

async def downstream() -> None:
try:
Expand Down
14 changes: 7 additions & 7 deletions src/ai/backend/client/cli/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,18 @@ async def web_handler(request):
try:
# We treat all requests and responses as streaming universally
# to be a transparent proxy.
api_rqst = Request(
api_request = Request(
request.method,
path,
request.content,
params=request.query,
)
_translate_headers(api_rqst, request)
_translate_headers(api_request, request)
if "Content-Type" in request.headers:
api_rqst.content_type = request.content_type # set for signing
api_request.content_type = request.content_type # set for signing
# Uploading request body happens at the entering of the block,
# and downloading response body happens in the read loop inside.
async with api_rqst.fetch() as up_resp:
async with api_request.fetch() as up_resp:
down_resp = web.StreamResponse()
down_resp.set_status(up_resp.status, up_resp.reason)
down_resp.headers.update(up_resp.headers)
Expand Down Expand Up @@ -164,15 +164,15 @@ async def web_handler(request):
async def websocket_handler(request):
path = re.sub(r"^/?v(\d+)/", "/", request.path)
try:
api_rqst = Request(
api_request = Request(
request.method,
path,
request.content,
params=request.query,
content_type=request.content_type,
)
_translate_headers(api_rqst, request)
async with api_rqst.connect_websocket() as up_conn:
_translate_headers(api_request, request)
async with api_request.connect_websocket() as up_conn:
down_conn = web.WebSocketResponse()
await down_conn.prepare(request)
web_socket_proxy = WebSocketProxy(up_conn, down_conn)
Expand Down
4 changes: 2 additions & 2 deletions src/ai/backend/client/cli/session/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ async def run(self) -> None:
if len(self.envs.keys()) > 0:
params["envs"] = json.dumps(self.envs)

api_rqst = Request("GET", path, b"", params=params, content_type="application/json")
async with api_rqst.connect_websocket() as ws:
api_request = Request("GET", path, b"", params=params, content_type="application/json")
async with api_request.connect_websocket() as ws:

async def downstream() -> None:
try:
Expand Down
4 changes: 2 additions & 2 deletions src/ai/backend/client/func/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -1051,12 +1051,12 @@ async def stream_app_info(self) -> Mapping[str, Any]:
params["owner_access_key"] = self.owner_access_key
prefix = get_naming(api_session.get().api_version, "path")
id_or_name = get_id_or_name(api_session.get().api_version, self)
api_rqst = Request(
api_request = Request(
"GET",
f"/stream/{prefix}/{id_or_name}/apps",
params=params,
)
async with api_rqst.fetch() as resp:
async with api_request.fetch() as resp:
return await resp.json()

@api_function
Expand Down
28 changes: 14 additions & 14 deletions src/ai/backend/web/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,25 +188,25 @@ async def web_handler(request: web.Request, *, is_anonymous=False) -> web.Stream
api_session.aiohttp_session.cookie_jar.update_cookies(request.cookies)
# We treat all requests and responses as streaming universally
# to be a transparent proxy.
api_rqst = Request(
api_request = Request(
request.method,
path,
payload,
params=request.query,
override_api_version=request_api_version,
)
if "Content-Type" in request.headers:
api_rqst.content_type = request.content_type # set for signing
api_rqst.headers["Content-Type"] = request.headers[
api_request.content_type = request.content_type # set for signing
api_request.headers["Content-Type"] = request.headers[
"Content-Type"
] # preserve raw value
if "Content-Length" in request.headers and not secure_context:
api_rqst.headers["Content-Length"] = request.headers["Content-Length"]
api_request.headers["Content-Length"] = request.headers["Content-Length"]
if "Content-Length" in request.headers and secure_context:
api_rqst.headers["Content-Length"] = str(decrypted_payload_length)
api_request.headers["Content-Length"] = str(decrypted_payload_length)
for hdr in HTTP_HEADERS_TO_FORWARD:
if request.headers.get(hdr) is not None:
api_rqst.headers[hdr] = request.headers[hdr]
api_request.headers[hdr] = request.headers[hdr]
if proxy_path == "pipeline":
session_id = request.headers.get("X-BackendAI-SessionID", "")
if not (sso_token := request.headers.get("X-BackendAI-SSO")):
Expand All @@ -222,11 +222,11 @@ async def web_handler(request: web.Request, *, is_anonymous=False) -> web.Stream
"access_key": api_session.config.access_key, # since 23.03.10
}
sso_token = jwt.encode(payload, key=jwt_secret, algorithm="HS256")
api_rqst.headers["X-BackendAI-SSO"] = sso_token
api_rqst.headers["X-BackendAI-SessionID"] = session_id
api_request.headers["X-BackendAI-SSO"] = sso_token
api_request.headers["X-BackendAI-SessionID"] = session_id
# Uploading request body happens at the entering of the block,
# and downloading response body happens in the read loop inside.
async with api_rqst.fetch() as up_resp:
async with api_request.fetch() as up_resp:
down_resp = web.StreamResponse()
down_resp.set_status(up_resp.status, up_resp.reason)
down_resp.headers.update(up_resp.headers)
Expand Down Expand Up @@ -294,7 +294,7 @@ async def web_plugin_handler(request, *, is_anonymous=False) -> web.StreamRespon
fill_forwarding_hdrs_to_api_session(request, api_session)
# Deliver cookie for token-based authentication.
api_session.aiohttp_session.cookie_jar.update_cookies(request.cookies)
api_rqst = Request(
api_request = Request(
request.method,
path,
content,
Expand All @@ -304,8 +304,8 @@ async def web_plugin_handler(request, *, is_anonymous=False) -> web.StreamRespon
)
for hdr in HTTP_HEADERS_TO_FORWARD:
if request.headers.get(hdr) is not None:
api_rqst.headers[hdr] = request.headers[hdr]
async with api_rqst.fetch() as up_resp:
api_request.headers[hdr] = request.headers[hdr]
async with api_request.fetch() as up_resp:
down_resp = web.StreamResponse()
down_resp.set_status(up_resp.status, up_resp.reason)
down_resp.headers.update(up_resp.headers)
Expand Down Expand Up @@ -385,15 +385,15 @@ async def websocket_handler(request, *, is_anonymous=False) -> web.StreamRespons
async with api_session:
request_api_version = request.headers.get("X-BackendAI-Version", None)
fill_forwarding_hdrs_to_api_session(request, api_session)
api_rqst = Request(
api_request = Request(
request.method,
path,
request.content,
params=request.query,
content_type=request.content_type,
override_api_version=request_api_version,
)
async with api_rqst.connect_websocket() as up_conn:
async with api_request.connect_websocket() as up_conn:
down_conn = web.WebSocketResponse()
await down_conn.prepare(request)
web_socket_proxy = WebSocketProxy(up_conn.raw_websocket, down_conn)
Expand Down
Loading