fix(sub2api): enable JD01 sentinel without docker build
This commit is contained in:
@@ -100,16 +100,11 @@ export interface CodexPoolSentinelManifestOptions {
|
||||
}
|
||||
|
||||
export function codexPoolSentinelRuntimeImage(config: CodexPoolSentinelConfig): CodexPoolSentinelImageTarget {
|
||||
const baseTag = config.image
|
||||
.replace(/[^A-Za-z0-9_.-]+/gu, "-")
|
||||
.replace(/^-+|-+$/gu, "")
|
||||
.slice(0, 80) || "python";
|
||||
const tag = `${baseTag}-openai-${config.sdk.openaiPythonVersion}`;
|
||||
const repository = "127.0.0.1:5000/platform-infra/sub2api-account-sentinel";
|
||||
const [repository, tag = "latest"] = config.image.split(":");
|
||||
return {
|
||||
baseImage: config.image,
|
||||
runtimeImage: `${repository}:${tag}`,
|
||||
repository,
|
||||
runtimeImage: config.image,
|
||||
repository: repository ?? config.image,
|
||||
tag,
|
||||
};
|
||||
}
|
||||
@@ -446,14 +441,27 @@ ${proxyEnv}
|
||||
export function sentinelContainerShellCommand(config: CodexPoolSentinelConfig): string {
|
||||
return [
|
||||
"set -eu",
|
||||
"python3 - <<'PY'",
|
||||
`OPENAI_PYTHON_VERSION=${JSON.stringify(config.sdk.openaiPythonVersion)}`,
|
||||
"if ! python3 - <<'PY'",
|
||||
"import importlib.metadata",
|
||||
`expected = ${JSON.stringify(config.sdk.openaiPythonVersion)}`,
|
||||
"import os",
|
||||
"expected = os.environ['OPENAI_PYTHON_VERSION']",
|
||||
"try:",
|
||||
" current = importlib.metadata.version('openai')",
|
||||
"except importlib.metadata.PackageNotFoundError:",
|
||||
" current = None",
|
||||
"if current != expected:",
|
||||
" raise SystemExit(1)",
|
||||
"PY",
|
||||
"then",
|
||||
" python3 -m pip install --no-cache-dir \"openai==$OPENAI_PYTHON_VERSION\"",
|
||||
"fi",
|
||||
"python3 - <<'PY'",
|
||||
"import importlib.metadata",
|
||||
"import os",
|
||||
"expected = os.environ['OPENAI_PYTHON_VERSION']",
|
||||
"current = importlib.metadata.version('openai')",
|
||||
"if current != expected:",
|
||||
" raise SystemExit(f'openai-python-version-mismatch expected={expected} current={current}')",
|
||||
"PY",
|
||||
"exec python3 /opt/sentinel/sentinel.py",
|
||||
|
||||
Reference in New Issue
Block a user