Skip to content

Commit

Permalink
html report now uses correct basedir (#439)
Browse files Browse the repository at this point in the history
  • Loading branch information
leondz authored Jan 26, 2024
1 parent c6126d8 commit e41db8e
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions garak/analyze/report_digest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,27 @@

import jinja2

from garak import _config, _plugins
from garak import _config

templateLoader = jinja2.FileSystemLoader(searchpath=".")
print(_config.transient.basedir)
templateLoader = jinja2.FileSystemLoader(searchpath=_config.transient.basedir)
templateEnv = jinja2.Environment(loader=templateLoader)

header_template = templateEnv.get_template(
"garak/analyze/templates/digest_header.jinja"
)
footer_template = templateEnv.get_template(
"garak/analyze/templates/digest_footer.jinja"
)
group_template = templateEnv.get_template("garak/analyze/templates/digest_group.jinja")
probe_template = templateEnv.get_template("garak/analyze/templates/digest_probe.jinja")
detector_template = templateEnv.get_template(
"garak/analyze/templates/digest_detector.jinja"
)
end_module = templateEnv.get_template("garak/analyze/templates/end_module.jinja")
header_template = templateEnv.get_template("analyze/templates/digest_header.jinja")
footer_template = templateEnv.get_template("analyze/templates/digest_footer.jinja")
group_template = templateEnv.get_template("analyze/templates/digest_group.jinja")
probe_template = templateEnv.get_template("analyze/templates/digest_probe.jinja")
detector_template = templateEnv.get_template("analyze/templates/digest_detector.jinja")
end_module = templateEnv.get_template("analyze/templates/end_module.jinja")


misp_descriptions = {}
if os.path.isfile("garak/resources/misp_descriptions.tsv"):
with open("garak/resources/misp_descriptions.tsv", "r", encoding="utf-8") as f:
if os.path.isfile(_config.transient.basedir / "garak/resources/misp_descriptions.tsv"):
with open(
_config.transient.basedir / "garak/resources/misp_descriptions.tsv",
"r",
encoding="utf-8",
) as f:
for line in f:
key, title, descr = line.strip().split("\t")
misp_descriptions[key] = (title, descr)
Expand Down

0 comments on commit e41db8e

Please sign in to comment.