Skip to content

Commit

Permalink
don't skip listing probes in 100%-pass-rate modules (#781)
Browse files Browse the repository at this point in the history
* don't skip listing probes in 100%-pass-rate modules

* add config option for hiding/showing reports of modules where score is 100%

* ensure encoding for stdout on launchable scripts

Signed-off-by: Jeffrey Martin <jemartin@nvidia.com>

---------

Signed-off-by: Jeffrey Martin <jemartin@nvidia.com>
Co-authored-by: Jeffrey Martin <jemartin@nvidia.com>
  • Loading branch information
leondz and jmartin-tech committed Jul 30, 2024
1 parent 4e30a3f commit 9df0d8e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions garak/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ def main():


if __name__ == "__main__":
sys.stdout.reconfigure(encoding="utf-8")
main()
8 changes: 6 additions & 2 deletions garak/analyze/report_digest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

from garak import _config

if not _config.loaded:
_config.load_config()

templateLoader = jinja2.FileSystemLoader(
searchpath=_config.transient.package_dir / "analyze" / "templates"
)
Expand Down Expand Up @@ -174,7 +177,7 @@ def compile_digest(report_path, taxonomy=_config.reporting.taxonomy):
}
)

if top_score < 100.0:
if top_score < 100.0 or _config.reporting.show_100_pass_modules:
res = cursor.execute(
f"select probe_module, probe_class, avg(score)*100 as s from results where probe_group='{probe_group}' group by probe_class order by s asc, probe_class asc;"
)
Expand Down Expand Up @@ -226,9 +229,10 @@ def compile_digest(report_path, taxonomy=_config.reporting.taxonomy):


if __name__ == "__main__":
sys.stdout.reconfigure(encoding="utf-8")
report_path = sys.argv[1]
taxonomy = None
if len(sys.argv) == 3:
taxonomy = sys.argv[2]
digest_content = compile_digest(report_path, taxonomy=taxonomy)
print(digest_content.encode("utf-8"))
print(digest_content)
1 change: 1 addition & 0 deletions garak/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,5 @@ def interactive_mode():


if __name__ == "__main__":
sys.stdout.reconfigure(encoding="utf-8")
interactive_mode()
3 changes: 2 additions & 1 deletion garak/resources/garak.core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ plugins:
reporting:
report_prefix:
taxonomy:
report_dir: garak_runs
report_dir: garak_runs
show_100_pass_modules: true

0 comments on commit 9df0d8e

Please sign in to comment.