-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Decouple the prompt set type (practice, official) from its file name (#…
…801) * decouple the file name from the prompt type * use new prompt set logic * decouple prompt set type and locale from file name * use new prompt set logic that decouples the prompt set type and locale from its filename * noop; formatting * change prompt set key for consistency * inject the prompt sets instead of using the global prompt set dict, for better testing * remove prompt_sets from where it doesn't belong conceptually
- Loading branch information
1 parent
5943f58
commit 9337d40
Showing
12 changed files
with
113 additions
and
89 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
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
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,33 @@ | ||
from modelgauge.secret_values import RequiredSecret, SecretDescription | ||
|
||
|
||
class ModellabFileDownloadToken(RequiredSecret): | ||
@classmethod | ||
def description(cls) -> SecretDescription: | ||
return SecretDescription( | ||
scope="modellab_files", | ||
key="token", | ||
instructions="Please ask MLCommons admin for permission.", | ||
) | ||
|
||
|
||
# file name format: | ||
# {prefix}_{version}_{type}(_{locale})_prompt_set_release | ||
PROMPT_SETS = { | ||
"practice": "airr_official_1.0_practice_prompt_set_release", | ||
"official": "airr_official_1.0_heldback_prompt_set_release", | ||
"practice_fr_fr": "airr_official_1.0_practice_fr_fr_prompt_set_release", | ||
} | ||
PROMPT_SET_DOWNLOAD_HOST = "ailuminate.mlcommons.org" | ||
|
||
|
||
def prompt_set_file_base_name(prompt_set: str, prompt_sets: dict = PROMPT_SETS) -> str: | ||
filename = prompt_sets.get(prompt_set, None) | ||
return filename | ||
|
||
|
||
def validate_prompt_set(prompt_set: str, prompt_sets: dict = PROMPT_SETS) -> bool: | ||
filename = prompt_set_file_base_name(prompt_set, prompt_sets) | ||
if not filename: | ||
raise ValueError(f"Invalid prompt set {prompt_set}. Must be one of {prompt_sets.keys()}.") | ||
return True |
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
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
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,19 @@ | ||
import pytest | ||
from modelgauge.prompt_sets import ( | ||
PROMPT_SETS, | ||
prompt_set_file_base_name, | ||
validate_prompt_set, | ||
) # usort: skip | ||
|
||
|
||
def test_file_base_name(): | ||
assert prompt_set_file_base_name("bad") is None | ||
assert prompt_set_file_base_name("practice") == PROMPT_SETS["practice"] | ||
assert prompt_set_file_base_name("practice", PROMPT_SETS) == PROMPT_SETS["practice"] | ||
|
||
|
||
def test_validate_prompt_set(): | ||
for s in PROMPT_SETS.keys(): | ||
assert validate_prompt_set(s, PROMPT_SETS) | ||
with pytest.raises(ValueError): | ||
validate_prompt_set("should raise") |
Oops, something went wrong.