MAINT: Bring GCG under Ruff and ty checks#2218
Open
romanlutz wants to merge 2 commits into
Open
Conversation
Bring the GCG prompt generator under the repository Ruff and ty checks, clean up the implementation to satisfy those checks, and preserve compatibility for the candidate filter API. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: e5f725f4-b97c-4fb9-b49c-a1db82f68399
Exercise the validation, logging, worker startup, annealing, and extension error paths added by the GCG tooling cleanup. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: e5f725f4-b97c-4fb9-b49c-a1db82f68399
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
GCG was excluded from repository-wide Ruff and ty enforcement, allowing its implementation to drift from current project standards. This change removes those exclusions and makes the GCG prompt generator pass the same formatting, linting, and type-checking gates as the rest of
pyrit/.The cleanup adds precise typing and documentation, replaces suppressed findings with explicit validation, and preserves the legacy
LengthPreservingFilter(filter=...)keyword while introducing the clearerenabledname. It also fixes the non-verbose optimization loop so it iterates prompt indices consistently with the verbose path and adds fail-fast checks for invalid worker and gradient states.The local ty hook now installs the
allextra so optional GCG dependencies such as torch are available during checking.Tests and Documentation
uv run --no-sync pre-commit run check-yaml --files .pre-commit-config.yamluv run --no-sync pre-commit run ruff-format --all-filesuv run --no-sync pre-commit run ruff-check --all-filesuv run --no-sync pre-commit run ty-check --all-filesuv run --no-sync pytest -q tests\unit\executor\promptgen\gcg(172 passed)Updated GCG API and implementation docstrings as required by the newly enabled Ruff rules. JupyText was not run because no notebook or documentation sample changed.