diff --git a/src/helm/common/general.py b/src/helm/common/general.py index 289f117e3fb..9368c91e9a8 100644 --- a/src/helm/common/general.py +++ b/src/helm/common/general.py @@ -107,7 +107,7 @@ def ensure_file_downloaded( shell([downloader_executable, source_url, "-O", tmp_path]) else: try: - print("Downloading source_url") + hlog(f"Downloading {source_url}") urllib.request.urlretrieve(source_url, tmp_path) except Exception as e: if os.path.isfile(tmp_path): diff --git a/src/helm/common/test_general.py b/src/helm/common/test_general.py index daf7ad44a4d..515c4b9500e 100644 --- a/src/helm/common/test_general.py +++ b/src/helm/common/test_general.py @@ -25,6 +25,25 @@ def test_ensure_file_downloaded(): shutil.rmtree("test-zip") +def test_ensure_file_downloaded_logs_url(monkeypatch, tmp_path): + source_url = "https://example.invalid/path/file.txt" + target_path = str(tmp_path / "file.txt") + messages = [] + + def fake_urlretrieve(url, filename): + with open(filename, "w") as f: + f.write("contents") + + monkeypatch.setattr("helm.common.general.hlog", messages.append) + monkeypatch.setattr("urllib.request.urlretrieve", fake_urlretrieve) + + ensure_file_downloaded(source_url, target_path) + + assert os.path.exists(target_path) + assert messages[0] == f"Downloading {source_url}" + assert len(messages) == 2 + + def test_format_tags(): tags = ["tag_1", "tag_2", "tag_3"] assert format_tags(tags) == "[tag_1,tag_2,tag_3]"