gigadoc_ws.py: поддержка пути в --sdk-host; test_fpg.py: переведён на DNR-стенд (bearer subprotocol, Origin, хосты с путём)
This commit is contained in:
1 parent
eb1c7ae276
commit
f11ec6298d
2 files changed
+72
-15
No files matched your search
+28
-3
@@ -211,6 +211,22 @@ def normalize_prefix(prefix: str) -> str:
|
||||
return prefix.rstrip("/")
|
||||
|
||||
|
||||
def split_host_path(host: str) -> tuple:
|
||||
"""Разделить 'host/path' на (scheme, hostname, base_path).
|
||||
|
||||
Поддерживает варианты: "domain.com", "domain.com/v1/giga",
|
||||
"https://domain.com/v1/giga". Схема возвращается без "://".
|
||||
"""
|
||||
host = host.strip().rstrip("/")
|
||||
scheme = ""
|
||||
if "://" in host:
|
||||
scheme, host = host.split("://", 1)
|
||||
parts = host.split("/", 1)
|
||||
hostname = parts[0]
|
||||
base_path = "/" + parts[1] if len(parts) > 1 else ""
|
||||
return scheme, hostname, base_path
|
||||
|
||||
|
||||
def build_ssl_context(
|
||||
insecure: bool,
|
||||
) -> Optional[ssl.SSLContext]:
|
||||
@@ -329,7 +345,8 @@ async def create_predict_session(
|
||||
)
|
||||
|
||||
url = (
|
||||
f"https://{args.sdk_host}"
|
||||
f"https://{args.sdk_hostname}"
|
||||
f"{args.sdk_base_path}"
|
||||
f"{rest_prefix}/predict/new"
|
||||
)
|
||||
|
||||
@@ -494,7 +511,8 @@ async def websocket_predict(
|
||||
for port in ports:
|
||||
|
||||
ws_url = (
|
||||
f"wss://{args.sdk_host}:{port}"
|
||||
f"wss://{args.sdk_hostname}:{port}"
|
||||
f"{args.sdk_base_path}"
|
||||
f"{ws_prefix}/{uid}/image"
|
||||
)
|
||||
|
||||
@@ -918,7 +936,8 @@ async def delete_predict_session(
|
||||
)
|
||||
|
||||
url = (
|
||||
f"https://{args.sdk_host}"
|
||||
f"https://{args.sdk_hostname}"
|
||||
f"{args.sdk_base_path}"
|
||||
f"{rest_prefix}/predict/{uid}"
|
||||
)
|
||||
|
||||
@@ -993,6 +1012,12 @@ async def main():
|
||||
|
||||
args = parse_args()
|
||||
|
||||
# sdk_host может содержать путь (domain.com/v1/giga) —
|
||||
# разделяем на hostname и base_path.
|
||||
_scheme, args.sdk_hostname, args.sdk_base_path = split_host_path(
|
||||
args.sdk_host
|
||||
)
|
||||
|
||||
setup_logging(
|
||||
args.verbose
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user