chore(repo): replace app symlink/submodule with in-repo app directory; enable committing app/Dockerfile and tooling\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
1 parent
a12270ad01
commit
ae2c674b81
25 files changed
+3417
-1
No files matched your search
@@ -0,0 +1,32 @@
|
||||
import importlib
|
||||
import os
|
||||
import unittest
|
||||
|
||||
|
||||
def _set_required_env() -> None:
|
||||
os.environ["SCW_ACCESS_KEY"] = "key0"
|
||||
os.environ["SCW_SECRET_KEY"] = "key1"
|
||||
os.environ["SCW_DEFAULT_ORGANIZATION_ID"] = "key2"
|
||||
os.environ["SCW_DEFAULT_PROJECT_ID"] = "key3"
|
||||
os.environ["SCW_SERVERLESS"] = "key4"
|
||||
|
||||
|
||||
class ApiClientModelSelectionTests(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
_set_required_env()
|
||||
import migration_pipeline.api_client as api_client
|
||||
|
||||
self.api_client = importlib.reload(api_client)
|
||||
|
||||
def test_default_model_family_is_glm(self) -> None:
|
||||
self.assertEqual(self.api_client.get_selected_model_family(), "glm")
|
||||
self.assertEqual(self.api_client.select_model(10), "glm-5.2")
|
||||
|
||||
def test_switch_to_qwen_model(self) -> None:
|
||||
self.api_client.set_model_family("qwen")
|
||||
self.assertEqual(self.api_client.select_model(10), "qwen3.5-397b-a17b")
|
||||
|
||||
def test_invalid_model_family_raises(self) -> None:
|
||||
with self.assertRaises(ValueError):
|
||||
self.api_client.set_model_family("invalid")
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
import importlib
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
class ConfigEnvLoadingTests(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self._old_cwd = Path.cwd()
|
||||
self._keys = [
|
||||
"SCW_ACCESS_KEY",
|
||||
"SCW_SECRET_KEY",
|
||||
"SCW_DEFAULT_ORGANIZATION_ID",
|
||||
"SCW_DEFAULT_PROJECT_ID",
|
||||
"SCW_SERVERLESS",
|
||||
]
|
||||
self._backup = {k: os.environ.get(k) for k in self._keys}
|
||||
|
||||
def tearDown(self) -> None:
|
||||
os.chdir(self._old_cwd)
|
||||
for key, value in self._backup.items():
|
||||
if value is None:
|
||||
os.environ.pop(key, None)
|
||||
else:
|
||||
os.environ[key] = value
|
||||
|
||||
def _clear_env(self) -> None:
|
||||
for key in self._keys:
|
||||
os.environ.pop(key, None)
|
||||
|
||||
def test_import_uses_dotenv_fallback(self) -> None:
|
||||
self._clear_env()
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
os.chdir(tmp)
|
||||
Path(".env").write_text(
|
||||
"SCW_ACCESS_KEY=key0\n"
|
||||
"SCW_SECRET_KEY=key1\n"
|
||||
"SCW_DEFAULT_ORGANIZATION_ID=key2\n"
|
||||
"SCW_DEFAULT_PROJECT_ID=key3\n"
|
||||
"SCW_SERVERLESS=key4\n"
|
||||
)
|
||||
sys.modules.pop("migration_pipeline.config", None)
|
||||
config = importlib.import_module("migration_pipeline.config")
|
||||
self.assertEqual(config.SCW_SERVERLESS, "key4")
|
||||
self.assertEqual(
|
||||
config.BASE_URL,
|
||||
"https://api.scaleway.ai/key4/v1/chat/completions",
|
||||
)
|
||||
|
||||
def test_import_fails_when_required_env_missing(self) -> None:
|
||||
self._clear_env()
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
os.chdir(tmp)
|
||||
sys.modules.pop("migration_pipeline.config", None)
|
||||
with self.assertRaisesRegex(RuntimeError, "SCW_ACCESS_KEY"):
|
||||
importlib.import_module("migration_pipeline.config")
|
||||
@@ -0,0 +1,34 @@
|
||||
import sys
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
import run_migration
|
||||
|
||||
|
||||
class RunMigrationCliTests(unittest.TestCase):
|
||||
def test_model_defaults_to_glm(self) -> None:
|
||||
argv = [
|
||||
"run_migration.py",
|
||||
"--batch-id",
|
||||
"b1",
|
||||
"--file-list",
|
||||
"files.txt",
|
||||
]
|
||||
with patch.object(sys, "argv", argv):
|
||||
args = run_migration._parse_args()
|
||||
self.assertEqual(args.model, "glm")
|
||||
|
||||
def test_model_accepts_qwen(self) -> None:
|
||||
argv = [
|
||||
"run_migration.py",
|
||||
"--batch-id",
|
||||
"b1",
|
||||
"--file-list",
|
||||
"files.txt",
|
||||
"--model",
|
||||
"qwen",
|
||||
]
|
||||
with patch.object(sys, "argv", argv):
|
||||
args = run_migration._parse_args()
|
||||
self.assertEqual(args.model, "qwen")
|
||||
|
||||
Reference in new issue
Block a user