|
5 | 5 | from dstack._internal.core.errors import ConfigurationError |
6 | 6 | from dstack._internal.core.models.common import RegistryAuth |
7 | 7 | from dstack._internal.core.models.configurations import ( |
| 8 | + DEFAULT_MODEL_PROBE_TIMEOUT, |
| 9 | + DEFAULT_MODEL_PROBE_URL, |
8 | 10 | DevEnvironmentConfigurationParams, |
9 | 11 | RepoSpec, |
10 | 12 | parse_run_configuration, |
|
13 | 15 |
|
14 | 16 |
|
15 | 17 | class TestParseConfiguration: |
| 18 | + def test_service_model_sets_default_probes_when_probes_omitted(self): |
| 19 | + conf = { |
| 20 | + "type": "service", |
| 21 | + "commands": ["python3 -m http.server"], |
| 22 | + "port": 8000, |
| 23 | + "model": "meta-llama/Meta-Llama-3.1-8B-Instruct", |
| 24 | + } |
| 25 | + parsed = parse_run_configuration(conf) |
| 26 | + assert len(parsed.probes) == 1 |
| 27 | + probe = parsed.probes[0] |
| 28 | + assert probe.type == "http" |
| 29 | + assert probe.method == "post" |
| 30 | + assert probe.url == DEFAULT_MODEL_PROBE_URL |
| 31 | + assert probe.timeout == DEFAULT_MODEL_PROBE_TIMEOUT |
| 32 | + assert len(probe.headers) == 1 |
| 33 | + assert probe.headers[0].name == "Content-Type" |
| 34 | + assert probe.headers[0].value == "application/json" |
| 35 | + assert "meta-llama/Meta-Llama-3.1-8B-Instruct" in (probe.body or "") |
| 36 | + assert "max_tokens" in (probe.body or "") |
| 37 | + |
| 38 | + def test_service_model_does_not_override_explicit_probes(self): |
| 39 | + conf = { |
| 40 | + "type": "service", |
| 41 | + "commands": ["python3 -m http.server"], |
| 42 | + "port": 8000, |
| 43 | + "model": "meta-llama/Meta-Llama-3.1-8B-Instruct", |
| 44 | + "probes": [{"type": "http", "url": "/health"}], |
| 45 | + } |
| 46 | + parsed = parse_run_configuration(conf) |
| 47 | + assert len(parsed.probes) == 1 |
| 48 | + assert parsed.probes[0].url == "/health" |
| 49 | + |
| 50 | + def test_service_model_explicit_empty_probes_no_default(self): |
| 51 | + conf = { |
| 52 | + "type": "service", |
| 53 | + "commands": ["python3 -m http.server"], |
| 54 | + "port": 8000, |
| 55 | + "model": "meta-llama/Meta-Llama-3.1-8B-Instruct", |
| 56 | + "probes": [], |
| 57 | + } |
| 58 | + parsed = parse_run_configuration(conf) |
| 59 | + assert len(parsed.probes) == 0 |
| 60 | + |
16 | 61 | def test_services_replicas_and_scaling(self): |
17 | 62 | def test_conf(replicas: Any, scaling: Optional[Any] = None): |
18 | 63 | conf = { |
|
0 commit comments