Skip to content

Commit c323c99

Browse files
authored
fix: modifications to granite formatter tests (#703)
* fix: properly mark generative tests in granite formatter tests * fix: move g-formatter test yaml retrieval to test time
1 parent 93d0bd4 commit c323c99

1 file changed

Lines changed: 19 additions & 9 deletions

File tree

test/formatters/granite/test_intrinsics_formatters.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,17 @@ class YamlJsonCombo(pydantic.BaseModel):
7373
"""Base model on which the target adapter was trained. Should be small enough to
7474
run on the CI server."""
7575

76-
@pydantic.model_validator(mode="after")
77-
def _maybe_download_yaml(self):
76+
def _resolve_yaml(self):
7877
"""
7978
If YAML file is not provided, download one based on other attributes of this
80-
object.
79+
object. Called at fixture creation (execution time) to prevent collection time errors.
8180
"""
8281
if not self.yaml_file:
8382
self.yaml_file = intrinsics_util.obtain_io_yaml(
84-
self.task, self.base_model_id, self.repo_id, revision=self.revision
83+
self.task,
84+
self.base_model_id,
85+
self.repo_id,
86+
revision=self.revision, # type: ignore
8587
)
8688
return self
8789

@@ -290,7 +292,7 @@ def _yaml_json_combo(request: pytest.FixtureRequest) -> YamlJsonCombo:
290292
291293
Returns test configuration.
292294
"""
293-
return _YAML_JSON_COMBOS[request.param]
295+
return _YAML_JSON_COMBOS[request.param]._resolve_yaml()
294296

295297

296298
@pytest.fixture(
@@ -306,7 +308,7 @@ def _yaml_json_combo_no_alora(request: pytest.FixtureRequest) -> YamlJsonCombo:
306308
Returns tuple of short name, YAML file, JSON file, model directory, and
307309
arguments file.
308310
"""
309-
return _YAML_JSON_COMBOS_NO_ALORA[request.param]
311+
return _YAML_JSON_COMBOS_NO_ALORA[request.param]._resolve_yaml()
310312

311313

312314
@pytest.fixture(
@@ -318,7 +320,7 @@ def _yaml_json_combo_with_model(request: pytest.FixtureRequest) -> YamlJsonCombo
318320
"""Version of :func:`_yaml_json_combo()` fixture with only the inputs that have
319321
models.
320322
"""
321-
return _YAML_JSON_COMBOS_WITH_MODEL[request.param]
323+
return _YAML_JSON_COMBOS_WITH_MODEL[request.param]._resolve_yaml()
322324

323325

324326
@pytest.fixture(
@@ -330,7 +332,7 @@ def _yaml_json_combo_with_lora_model(request: pytest.FixtureRequest) -> YamlJson
330332
"""Version of :func:`_yaml_json_combo()` fixture with only the inputs that have
331333
non-aLoRA models.
332334
"""
333-
return _YAML_JSON_COMBOS_WITH_LORA_MODEL[request.param]
335+
return _YAML_JSON_COMBOS_WITH_LORA_MODEL[request.param]._resolve_yaml()
334336

335337

336338
@pytest.fixture(
@@ -342,7 +344,7 @@ def _yaml_json_combo_for_ollama(request: pytest.FixtureRequest) -> YamlJsonCombo
342344
"""Version of :func:`_yaml_json_combo()` fixture with only inputs suitable
343345
for an Ollama backend.
344346
"""
345-
return _YAML_JSON_COMBOS_FOR_OLLAMA[request.param]
347+
return _YAML_JSON_COMBOS_FOR_OLLAMA[request.param]._resolve_yaml()
346348

347349

348350
def test_no_orphan_files():
@@ -566,6 +568,14 @@ def _round_floats(json_data, num_digits: int = 2):
566568
return result
567569

568570

571+
@pytest.mark.huggingface
572+
@pytest.mark.llm
573+
@pytest.mark.requires_gpu
574+
@pytest.mark.requires_heavy_ram
575+
@pytest.mark.requires_gpu_isolation # Activate GPU memory isolation
576+
@pytest.mark.skipif(
577+
int(os.environ.get("CICD", 0)) == 1, reason="Skipping HuggingFace tests in CI"
578+
)
569579
def test_run_transformers(yaml_json_combo_with_model, gh_run):
570580
"""
571581
Run the target model end-to-end on transformers.

0 commit comments

Comments
 (0)