forked from luopingyi/xc_agent_platform_demo
live: EXTERNAL_SERVICE_TOKEN precedence, baked A/B candidates, model|gpu ledger from task/page modelId+gpuType, string total fix, Iluvatar/MTT enums (59 tests)
This commit is contained in:
@@ -12,10 +12,10 @@ from typing import Optional
|
||||
|
||||
# Community alias order (level C); we only check presence, never echo values.
|
||||
_TOKEN_ENV_KEYS = (
|
||||
"EXTERNAL_SERVICE_TOKEN",
|
||||
"XC_TOKEN_FILE",
|
||||
"XC_TOKEN",
|
||||
"MODELHUB_XC_TOKEN",
|
||||
"EXTERNAL_SERVICE_TOKEN",
|
||||
)
|
||||
|
||||
|
||||
@@ -62,20 +62,9 @@ def _token_from_file(path: str) -> bool:
|
||||
|
||||
def external_service_token_present() -> bool:
|
||||
"""Whether any known token env / file alias is present (boolean only)."""
|
||||
for key in _TOKEN_ENV_KEYS:
|
||||
raw = os.environ.get(key)
|
||||
if raw is None:
|
||||
continue
|
||||
value = raw.strip()
|
||||
if not value:
|
||||
continue
|
||||
if key == "XC_TOKEN_FILE":
|
||||
if _token_from_file(value):
|
||||
return True
|
||||
continue
|
||||
# Reject obvious placeholders (community practice, level C)
|
||||
lowered = value.lower()
|
||||
if lowered in ("tmp", "placeholder", "changeme", "xxx"):
|
||||
continue
|
||||
from .task_add_client import resolve_token_with_source
|
||||
try:
|
||||
resolve_token_with_source()
|
||||
return True
|
||||
return False
|
||||
except (ValueError, OSError, UnicodeError):
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user