fix(loading): forward download_config to LocalEvaluationModuleFactory#755
Open
xodn348 wants to merge 1 commit intohuggingface:mainfrom
Open
fix(loading): forward download_config to LocalEvaluationModuleFactory#755xodn348 wants to merge 1 commit intohuggingface:mainfrom
xodn348 wants to merge 1 commit intohuggingface:mainfrom
Conversation
When evaluation_module_factory resolves a local .py path or a directory containing a metric script, it creates a LocalEvaluationModuleFactory without passing the caller's download_config. This means extra-module downloads (e.g. a requirements file fetched from a remote URL) silently use a default DownloadConfig, ignoring settings such as local_files_only, cache_dir, or proxies that the caller explicitly supplied. Pass download_config to both LocalEvaluationModuleFactory call sites. Also add regression tests that spy on the factory constructor to verify the argument is forwarded in both the .py-path branch and the directory-path branch. Fixes huggingface#709
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
evaluation_module_factoryhas two code paths for loading a local metric script (lines 619–621 and 625–627 ofsrc/evaluate/loading.py). Both paths construct aLocalEvaluationModuleFactorybut omit thedownload_configargument that the caller explicitly passed in. As a result, the factory falls back to a blankDownloadConfig()for any secondary downloads it performs (e.g. fetching external requirements files declared in the script's_HF_REQUIRES_PYTHONimports). This silently ignores caller-supplied settings such aslocal_files_only=True,cache_dir, or custom proxies, which can cause unexpected network requests or connection failures in air-gapped / offline environments.The fix is a two-line change: pass
download_config=download_configto theLocalEvaluationModuleFactoryconstructor in both branches. The class already accepts and uses the parameter — it was just never forwarded fromevaluation_module_factory.Two regression tests were added that spy on
LocalEvaluationModuleFactory.__init__(viaunittest.mock.patch(wraps=…)) to assert thedownload_configobject is forwarded for both the direct-.py-path branch and the directory-path branch.Issue
Fixes #709
Local verification
(The other tests in
test_load.pyrequire connectivity to huggingface.co and fail withConnectionError 403in this offline environment; they fail identically on the unmodifiedmainbranch.)Risk
The change is a pure addition of a previously-missing argument that was already declared in
LocalEvaluationModuleFactory.__init__. It does not alter the existingdownload_configobject, does not change the fallback default for callers that do not pass one (they still getDownloadConfig()via theor DownloadConfig()guard in the factory constructor), and has no effect on Hub-based loading paths. The only behaviour change is that callers who do pass adownload_configwill now have it respected for local scripts — closing a silent data-loss bug.