Skip to content

Commit e355251

Browse files
committed
Fix tests
1 parent 2f4055e commit e355251

File tree

5 files changed

+29
-27
lines changed

5 files changed

+29
-27
lines changed

tests/vec_inf/cli/test_cli.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,23 @@ def test_launch_command_success(runner):
2626
# for Rich table rendering
2727
mock_response = MagicMock()
2828
mock_response.config = {
29-
"slurm_job_id": "14933053",
30-
"model_name": "Meta-Llama-3.1-8B",
31-
"model_type": "LLM",
32-
"log_dir": "/tmp/test_logs",
33-
"partition": "gpu",
34-
"qos": "normal",
35-
"time": "1:00:00",
36-
"num_nodes": "1",
37-
"gpus_per_node": "1",
38-
"cpus_per_task": "8",
39-
"mem_per_node": "32G",
40-
"model_weights_parent_dir": "/model-weights",
41-
"vocab_size": "128000",
42-
"vllm_args": {"max_model_len": 8192},
43-
"env": {"CACHE": "/cache"},
44-
}
29+
"slurm_job_id": "14933053",
30+
"model_name": "Meta-Llama-3.1-8B",
31+
"model_type": "LLM",
32+
"log_dir": "/tmp/test_logs",
33+
"partition": "gpu",
34+
"qos": "normal",
35+
"time": "1:00:00",
36+
"num_nodes": "1",
37+
"gpus_per_node": "1",
38+
"cpus_per_task": "8",
39+
"mem_per_node": "32G",
40+
"model_weights_parent_dir": "/model-weights",
41+
"vocab_size": "128000",
42+
"venv": "/path/to/venv",
43+
"vllm_args": {"max_model_len": 8192},
44+
"env": {"CACHE": "/cache"},
45+
}
4546
mock_client.launch_model.return_value = mock_response
4647

4748
result = runner.invoke(cli, ["launch", "Meta-Llama-3.1-8B"])

tests/vec_inf/cli/test_helper.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def test_format_table_output(self):
3535
"mem_per_node": "32G",
3636
"model_weights_parent_dir": "/model-weights",
3737
"log_dir": "/tmp/logs",
38+
"venv": "/path/to/venv",
3839
"vllm_args": {"max_model_len": 8192, "enable_prefix_caching": True},
3940
"env": {"CACHE": "/cache"},
4041
}
@@ -63,6 +64,7 @@ def test_format_table_output_with_minimal_params(self):
6364
"mem_per_node": "16G",
6465
"model_weights_parent_dir": "/weights",
6566
"log_dir": "/logs",
67+
"venv": "/path/to/venv",
6668
"vllm_args": {},
6769
"env": {},
6870
}

tests/vec_inf/client/test_slurm_script_generator.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def singularity_params(self, basic_params):
5353
singularity = basic_params.copy()
5454
singularity.update(
5555
{
56-
"venv": "singularity",
56+
"venv": "apptainer",
5757
"bind": "/scratch:/scratch,/data:/data",
5858
"env": {
5959
"CACHE_DIR": "/cache",
@@ -109,7 +109,7 @@ def test_init_singularity(self, singularity_params):
109109
def test_init_singularity_no_bind(self, basic_params):
110110
"""Test Singularity initialization without additional binds."""
111111
params = basic_params.copy()
112-
params["venv"] = "singularity"
112+
params["venv"] = "apptainer"
113113
generator = SlurmScriptGenerator(params)
114114

115115
assert generator.params == params
@@ -185,7 +185,7 @@ def test_generate_launch_cmd_singularity(self, singularity_params):
185185
generator = SlurmScriptGenerator(singularity_params)
186186
launch_cmd = generator._generate_launch_cmd()
187187

188-
assert "exec --nv" in launch_cmd
188+
assert "apptainer exec --nv" in launch_cmd
189189
assert "--bind /path/to/model_weights/test-model" in launch_cmd
190190
assert "--bind /scratch:/scratch,/data:/data" in launch_cmd
191191
assert "source" not in launch_cmd
@@ -306,9 +306,9 @@ def batch_params(self):
306306
def batch_singularity_params(self, batch_params):
307307
"""Generate batch SLURM configuration parameters with Singularity."""
308308
singularity_params = batch_params.copy()
309-
singularity_params["venv"] = "singularity" # Set top-level venv to singularity
309+
singularity_params["venv"] = "apptainer" # Set top-level venv to apptainer
310310
for model_name in singularity_params["models"]:
311-
singularity_params["models"][model_name]["venv"] = "singularity"
311+
singularity_params["models"][model_name]["venv"] = "apptainer"
312312
singularity_params["models"][model_name]["bind"] = (
313313
"/scratch:/scratch,/data:/data"
314314
)
@@ -341,9 +341,9 @@ def test_init_singularity(self, batch_singularity_params):
341341
def test_init_singularity_no_bind(self, batch_params):
342342
"""Test Singularity initialization without additional binds."""
343343
params = batch_params.copy()
344-
params["venv"] = "singularity" # Set top-level venv to singularity
344+
params["venv"] = "apptainer" # Set top-level venv to apptainer
345345
for model_name in params["models"]:
346-
params["models"][model_name]["venv"] = "singularity"
346+
params["models"][model_name]["venv"] = "apptainer"
347347

348348
generator = BatchSlurmScriptGenerator(params)
349349

vec_inf/cli/_helper.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ def format_table_output(self) -> Table:
7676
table.add_row("Memory/Node", self.params["mem_per_node"])
7777

7878
# Add job config details
79-
table.add_row("Virtual Environment", self.params["venv"])
79+
if self.params.get("venv"):
80+
table.add_row("Virtual Environment", self.params["venv"])
8081
table.add_row(
8182
"Model Weights Directory",
8283
str(Path(self.params["model_weights_parent_dir"], self.model_name)),

vec_inf/client/_slurm_script_generator.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,7 @@ class BatchSlurmScriptGenerator:
193193
def __init__(self, params: dict[str, Any]):
194194
self.params = params
195195
self.script_paths: list[Path] = []
196-
self.use_container = (
197-
self.params["venv"] == "singularity" or self.params["venv"] == "apptainer"
198-
)
196+
self.use_container = self.params["venv"] == CONTAINER_MODULE_NAME
199197
for model_name in self.params["models"]:
200198
self.params["models"][model_name]["additional_binds"] = ""
201199
if self.params["models"][model_name].get("bind"):

0 commit comments

Comments
 (0)