Skip to content

Commit eb197f9

Browse files
committed
download public files instead of private or protected
1 parent 62b56ff commit eb197f9

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

plugins/validation_tests/test_object_creation.py

+24-26
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from modelgauge.load_plugins import load_plugins
1212
from modelgauge.locales import EN_US # see "workaround" below
1313
from modelgauge.prompt import SUTOptions, TextPrompt
14+
from modelgauge.prompt_sets import demo_prompt_set_url
1415
from modelgauge.record_init import InitializationRecord
1516
from modelgauge.sut import PromptResponseSUT, SUTResponse
1617
from modelgauge.sut_capabilities import AcceptsTextPrompt
@@ -24,18 +25,17 @@
2425

2526
# Ensure all the plugins are available during testing.
2627
load_plugins()
27-
# Some tests need to download a file from modellab, which requires a real auth token
28+
2829
_FAKE_SECRETS = fake_all_secrets()
2930

3031

3132
def ensure_public_dependencies(dependencies):
33+
"""Some tests are defined with dependencies that require an auth token to download them.
34+
In this test context, we substitute public files instead."""
3235
for k, d in dependencies.items():
3336
if isinstance(d, WebData):
34-
if "practice_prompt" in d.source_url or "heldback_prompt" in d.source_url:
35-
new_dependency = WebData(
36-
source_url=re.sub("(practice|heldback|official)_prompt", "demo_prompt", d.source_url)
37-
)
38-
dependencies[k] = new_dependency
37+
new_dependency = WebData(source_url=demo_prompt_set_url(d.source_url), headers=None)
38+
dependencies[k] = new_dependency
3939
return dependencies
4040

4141

@@ -63,26 +63,24 @@ def test_all_tests_construct_and_record_init(test_name):
6363
@flaky
6464
@pytest.mark.parametrize("test_name", [key for key, _ in TESTS.items() if key not in TOO_SLOW])
6565
def test_all_tests_make_test_items(tmp_path, test_name, shared_run_dir):
66-
# test = TESTS.make_instance(test_name, secrets=_FAKE_SECRETS)
67-
68-
# # TODO remove when localized files are handled better
69-
# # workaround
70-
# if isinstance(test, BaseSafeTestVersion1) and test.locale != EN_US:
71-
# return
72-
73-
# if isinstance(test, PromptResponseTest):
74-
# test_data_path = os.path.join(shared_run_dir, test.__class__.__name__)
75-
# dependencies = ensure_public_dependencies(test.get_dependencies())
76-
77-
# dependency_helper = FromSourceDependencyHelper(
78-
# test_data_path,
79-
# dependencies,
80-
# required_versions={},
81-
# )
82-
83-
# test_items = test.make_test_items(dependency_helper)
84-
# assert len(test_items) > 0
85-
pass # to silence the broken test until we fix it properly
66+
test = TESTS.make_instance(test_name, secrets=_FAKE_SECRETS)
67+
68+
# TODO remove when localized files are handled better
69+
# workaround
70+
if isinstance(test, BaseSafeTestVersion1) and test.locale != EN_US:
71+
return
72+
73+
if isinstance(test, PromptResponseTest):
74+
test_data_path = os.path.join(shared_run_dir, test.__class__.__name__)
75+
dependencies = ensure_public_dependencies(test.get_dependencies())
76+
dependency_helper = FromSourceDependencyHelper(
77+
test_data_path,
78+
dependencies,
79+
required_versions={},
80+
)
81+
82+
test_items = test.make_test_items(dependency_helper)
83+
assert len(test_items) > 0
8684

8785

8886
@pytest.mark.parametrize("sut_name", [key for key, _ in SUTS.items()])

0 commit comments

Comments
 (0)