-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
avoid attempt w/ empty prompt; use centralised colours; add fileforma…
…ts tests
- Loading branch information
Showing
2 changed files
with
40 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import os | ||
|
||
import garak._config | ||
import garak._plugins | ||
|
||
import garak.probes.base | ||
import garak.probes.fileformats | ||
import garak.attempt | ||
|
||
|
||
def test_hf_files_load(): | ||
p = garak.probes.fileformats.HF_Files() | ||
assert isinstance(p, garak.probes.base.Probe) | ||
|
||
|
||
def test_hf_files_hf_repo(): | ||
p = garak._plugins.load_plugin("probes.fileformats.HF_Files") | ||
garak._config.plugins.generators["huggingface"] = {"Model": {"name": "gpt2"}} | ||
g = garak._plugins.load_plugin( | ||
"generators.huggingface.Model", config_root=garak._config | ||
) | ||
r = p.probe(g) | ||
assert isinstance(r, list), ".probe should return a list" | ||
assert len(r) == 1, "HF_Files.probe() should return one attempt" | ||
assert isinstance( | ||
r[0], garak.attempt.Attempt | ||
), "HF_Files.probe() must return an Attempt" | ||
assert isinstance(r[0].outputs, list), "File list scan should return a list" | ||
assert len(r[0].outputs) > 0, "File list scan should return list of filenames" | ||
for filename in r[0].outputs: | ||
assert isinstance( | ||
filename, str | ||
), "File list scan should return list of string filenames" | ||
assert os.path.isfile(filename), "List of HF_Files paths should all be real" |