Compare commits
3 Commits
probe-2026
...
codex/clou
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
84c036e53a | ||
|
|
9e4af1c952 | ||
|
|
3cf0ca7420 |
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
__pycache__/
|
||||
*.pyc
|
||||
@@ -1,6 +1,11 @@
|
||||
FROM modelhubxc-4pd.tencentcloudcr.com/xc_agent_platform/python:3.11-slim
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
WORKDIR /app
|
||||
COPY requirements.txt /app/requirements.txt
|
||||
COPY requirements.lock /app/requirements.lock
|
||||
COPY wheels /wheels
|
||||
RUN pip install --no-cache-dir --no-index --find-links=/wheels --require-hashes -r /app/requirements.lock
|
||||
COPY app.py /app/app.py
|
||||
COPY network_probe.py /app/network_probe.py
|
||||
EXPOSE 8080
|
||||
CMD ["python", "/app/app.py"]
|
||||
|
||||
9
app.py
9
app.py
@@ -2,12 +2,19 @@
|
||||
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
||||
import json
|
||||
import os
|
||||
from threading import Thread
|
||||
from network_probe import run
|
||||
|
||||
metadata = {"name": "xc-cloud-build-probe", "version": "probe-20261026-01",
|
||||
external_token = os.environ.get("EXTERNAL_SERVICE_TOKEN", "")
|
||||
metadata = {"name": "xc-cloud-build-probe", "version": "probe-20261026-04",
|
||||
"strategyIdPresent": bool(os.environ.get("STRATEGY_ID")),
|
||||
"externalCredentialPresent": bool(external_token),
|
||||
"externalCredentialLength": len(external_token),
|
||||
"externalCredentialShape": "jwt-like" if external_token.count(".") == 2 else "opaque" if external_token else "empty",
|
||||
"credentialEnvironmentNames": sorted(name for name in os.environ
|
||||
if any(marker in name for marker in ("TOKEN", "AUTH", "CREDENTIAL", "SECRET", "API_KEY")))}
|
||||
print(json.dumps(metadata), flush=True)
|
||||
Thread(target=run, daemon=True).start()
|
||||
|
||||
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
|
||||
34
network_probe.py
Normal file
34
network_probe.py
Normal file
@@ -0,0 +1,34 @@
|
||||
"""Time public model metadata endpoints; no account credential is sent."""
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
import json
|
||||
import time
|
||||
from urllib.error import HTTPError, URLError
|
||||
from urllib.request import urlopen
|
||||
|
||||
|
||||
def run():
|
||||
urls = {
|
||||
"hf_mirror_api": "https://hf-mirror.com/api/models/Qwen/Qwen2.5-0.5B-Instruct",
|
||||
"hf_mirror_config": "https://hf-mirror.com/Qwen/Qwen2.5-0.5B-Instruct/resolve/main/config.json",
|
||||
"hf_official_api": "https://huggingface.co/api/models/Qwen/Qwen2.5-0.5B-Instruct",
|
||||
"modelscope_config": "https://modelscope.cn/models/Qwen/Qwen2.5-0.5B-Instruct/resolve/master/config.json",
|
||||
}
|
||||
|
||||
def check(item):
|
||||
name, url = item
|
||||
started = time.monotonic()
|
||||
value = {"endpoint": name}
|
||||
try:
|
||||
with urlopen(url, timeout=8) as response:
|
||||
body = response.read(262144)
|
||||
value.update(httpStatus=response.status, jsonValid=isinstance(json.loads(body), dict))
|
||||
except HTTPError as error:
|
||||
value.update(httpStatus=error.code, errorType=type(error).__name__)
|
||||
except (URLError, TimeoutError, ValueError, OSError) as error:
|
||||
value["errorType"] = type(error).__name__
|
||||
value["seconds"] = round(time.monotonic() - started, 2)
|
||||
return value
|
||||
|
||||
with ThreadPoolExecutor(max_workers=4) as executor:
|
||||
results = list(executor.map(check, urls.items()))
|
||||
print(json.dumps({"name": "xc-cloud-network-probe", "version": "probe-20261026-04", "results": results}), flush=True)
|
||||
7
requirements.lock
Normal file
7
requirements.lock
Normal file
@@ -0,0 +1,7 @@
|
||||
certifi==2026.10.23 --hash=sha256:e9b54de76e530bb6cf0ccd036787103acb58fd42ba930ea8bf948ddbaa2f61d1
|
||||
charset-normalizer==3.5.2 --hash=sha256:211d5a3eb6af8f513b8d4ca19a8c1b7accab1b5f0d3175f9826b03c1a920dc1f
|
||||
idna==3.20 --hash=sha256:ab7ae7122974553370f0bdb919e1a960b2cd1bc1ef0276416d896db81c14582c
|
||||
pycryptodome==3.23.0 --hash=sha256:c8987bd3307a39bc03df5c8e0e3d8be0c4c3518b7f044b0f4c15d1aa78f52575
|
||||
PyYAML==6.0.2 --hash=sha256:3ad2a3decf9aaba3d29c8f537ac4b243e36bef957511b4766cb0057d32b0be85
|
||||
requests==2.32.4 --hash=sha256:27babd3cda2a6d50b30443204ee89830707d396671944c998b5975b031ac2b2c
|
||||
urllib3==2.8.0 --hash=sha256:0cf3cae568d36aa9576b28dfb35f11328f1cb974ca7647d9475ebb86c75ac6e3
|
||||
3
requirements.txt
Normal file
3
requirements.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
pycryptodome==3.23.0
|
||||
PyYAML==6.0.2
|
||||
requests==2.32.4
|
||||
Binary file not shown.
BIN
wheels/certifi-2026.10.23-py3-none-any.whl
Normal file
BIN
wheels/certifi-2026.10.23-py3-none-any.whl
Normal file
Binary file not shown.
Binary file not shown.
BIN
wheels/idna-3.20-py3-none-any.whl
Normal file
BIN
wheels/idna-3.20-py3-none-any.whl
Normal file
Binary file not shown.
Binary file not shown.
BIN
wheels/requests-2.32.4-py3-none-any.whl
Normal file
BIN
wheels/requests-2.32.4-py3-none-any.whl
Normal file
Binary file not shown.
BIN
wheels/urllib3-2.8.0-py3-none-any.whl
Normal file
BIN
wheels/urllib3-2.8.0-py3-none-any.whl
Normal file
Binary file not shown.
Reference in New Issue
Block a user