Skip to content

tests: cover a completed parallel_attempts run#1816

Open
EphraiemSarabamoun wants to merge 1 commit into
NVIDIA:mainfrom
EphraiemSarabamoun:fix/338-parallel-attempts-run-test
Open

tests: cover a completed parallel_attempts run#1816
EphraiemSarabamoun wants to merge 1 commit into
NVIDIA:mainfrom
EphraiemSarabamoun:fix/338-parallel-attempts-run-test

Conversation

@EphraiemSarabamoun
Copy link
Copy Markdown

@EphraiemSarabamoun EphraiemSarabamoun commented May 30, 2026

This adds a test for the happy path of parallel_attempts, which issue #338 asks for.

The only existing run with --parallel_attempts is test_site_yaml_overrides_max_workers in tests/test_config.py, and it deliberately expects a ValueError from the max_workers cap. So the case the issue cares about, where parallel_attempts is greater than 1 and a run finishes successfully, was not tested anywhere.

The new test_parallel_attempts_run_completes runs garak end to end through garak.cli.main with --parallel_attempts set to both 1 and 4. It uses the cheap CPU only test.Blank generator and the test.Test probe with one generation, then asserts the run finishes without raising and that the parallel worker count landed in config as requested. This matches the test conditions in the issue, namely the test generator, one generation, a continuations style probe, and parallel_attempts in both the serial and parallel cases.

I picked test.Test rather than test.Blank as the probe on purpose. test.Test carries 8 prompts, so with one generation the run produces more than one attempt, and the test generator is parallel capable by default. That means the value greater than 1 case actually reaches the multiprocessing path in garak.probes.base.Probe._execute_all rather than quietly falling through to the serial branch, so the test exercises the thing it claims to.

Verification. I installed the package into a fresh venv with uv pip install -e the tests extra, then ran only this test by node id. Both parameter cases pass. I also ran black on the changed file and my added lines are clean.

Add a parametrized test that runs garak through garak.cli.main with
--parallel_attempts set to 1 and to 4, against the CPU-only test.Blank
generator and the multi-prompt test.Test probe, and asserts the run
completes without error. The only existing --parallel_attempts run
deliberately expects a ValueError from the max_workers cap, so the path
where parallel_attempts is greater than 1 and a run finishes was not
covered anywhere. test.Test carries 8 prompts, so the greater than 1
case actually reaches the multiprocessing path in Probe._execute_all.

Closes NVIDIA#338

Signed-off-by: Ephraiem Sarabamoun <ephraiemsam16@gmail.com>
@jmartin-tech jmartin-tech changed the title tests: cover a completed parallel_attempts run (issue #338) tests: cover a completed parallel_attempts run May 30, 2026
Comment thread tests/test_config.py
Comment thread tests/test_config.py
).split()
garak.cli.main(args)

assert _config.system.parallel_attempts == parallel_attempts
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

asserts should have a message describing the desired condition. e.g. "--parallel_atempts cli param should pass through to _config.system"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants