Skip to content

armgit / sie

Public Imported from GitHub
0

Open-source inference server and production cluster for all the models your agent needs.

fix(cli): honor the configured Hub fallback policy

svonava17a88bb4b867
diff --git a/packages/sie_server/src/sie_server/cli.py b/packages/sie_server/src/sie_server/cli.py
index 70f1e76dd..275036412 100644
--- a/packages/sie_server/src/sie_server/cli.py
+++ b/packages/sie_server/src/sie_server/cli.py
@@ -513,7 +513,12 @@ def serve(
"--cluster-cache",
help="Cluster cache URL (s3://, gs://, abfs(s)://, or oss://)",
),
- hf_fallback: bool = typer.Option(True, "--hf-fallback/--no-hf-fallback", help="Enable HuggingFace Hub fallback"),
+ hf_fallback: bool = typer.Option(
+ True,
+ "--hf-fallback/--no-hf-fallback",
+ envvar="SIE_HF_FALLBACK",
+ help="Enable HuggingFace Hub fallback",
+ ),
reload: bool = typer.Option(default=False, help="Enable auto-reload for development"),
tracing: bool = typer.Option(default=False, help="Enable OpenTelemetry tracing (exports to localhost:4317)"),
instrumentation: bool = typer.Option(False, "--instrumentation", "-i", help="Enable batch instrumentation logging"),
diff --git a/packages/sie_server/tests/test_cli_cache.py b/packages/sie_server/tests/test_cli_cache.py
new file mode 100644
index 000000000..e2bf0f1f8
--- /dev/null
+++ b/packages/sie_server/tests/test_cli_cache.py
@@ -0,0 +1,48 @@
+"""The serve CLI preserves cache policy unless an explicit flag overrides it."""
+
+import os
+from collections.abc import Iterator
+from pathlib import Path
+from unittest.mock import Mock
+
+import pytest
+from sie_sdk.cache import get_cache_config
+from sie_server import cli
+from typer.testing import CliRunner
+
+
[email protected](autouse=True)
+def isolated_environment(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> Iterator[None]:
+ saved = dict(os.environ)
+ for name in tuple(os.environ):
+ if name.startswith("SIE_"):
+ monkeypatch.delenv(name)
+ monkeypatch.setenv("SIE_DATA_DIR", str(tmp_path / "data"))
+ yield
+ os.environ.clear()
+ os.environ.update(saved)
+
+
[email protected]("environment", [None, "true", "false", "1", "0", "yes", "no"])
[email protected]("flag", [None, "--hf-fallback", "--no-hf-fallback"])
+def test_cli_cache_policy_precedence(
+ monkeypatch: pytest.MonkeyPatch, environment: str | None, flag: str | None
+) -> None:
+ if environment is not None:
+ monkeypatch.setenv("SIE_HF_FALLBACK", environment)
+ observed = []
+ run_server = Mock(side_effect=lambda **_kwargs: observed.append(get_cache_config().hf_fallback))
+ monkeypatch.setattr(cli, "run_server", run_server)
+ args = ["serve", "--host", "127.0.0.1"]
+ if flag is not None:
+ args.append(flag)
+
+ result = CliRunner().invoke(cli.app, args)
+
+ assert result.exit_code == 0, result.output
+ expected = (
+ flag == "--hf-fallback" if flag is not None else environment is None or environment in {"true", "1", "yes"}
+ )
+ assert observed == [expected]
+ assert os.environ["SIE_HF_FALLBACK"] == str(expected).lower()
+ run_server.assert_called_once()