Repository: nilearn/nilearn

Issue:
rename either `nilearn.datasets._utils._fetch_file` or `nilearn.datasets._utils._fetch_files`
rename either `nilearn.datasets.utils._fetch_file` or `nilearn.datasets.utils._fetch_files`

but having both of them differing by a single letter is just not OK

_Originally posted by @Remi-Gau in https://github.com/nilearn/nilearn/issues/4086#issuecomment-1783156630_
            


Discussion:

Resolving patch:
diff --git a/nilearn/datasets/_utils.py b/nilearn/datasets/_utils.py
--- a/nilearn/datasets/_utils.py
+++ b/nilearn/datasets/_utils.py
@@ -483,7 +483,7 @@ def close(self):
 
 
 @fill_doc
-def fetch_file(
+def fetch_single_file(
     url,
     data_dir,
     resume=True,
@@ -530,7 +530,7 @@ def fetch_file(
     if session is None:
         with requests.Session() as session:
             session.mount("ftp:", _NaiveFTPAdapter())
-            return fetch_file(
+            return fetch_single_file(
                 url,
                 data_dir,
                 resume=resume,
@@ -611,7 +611,7 @@ def fetch_file(
             except Exception:
                 if verbose > 0:
                     print("Resuming failed, try to download the whole file.")
-                return fetch_file(
+                return fetch_single_file(
                     url,
                     data_dir,
                     resume=False,
@@ -810,7 +810,7 @@ def fetch_files(data_dir, files, resume=True, verbose=1, session=None):
                 os.mkdir(temp_dir)
             md5sum = opts.get("md5sum", None)
 
-            dl_file = fetch_file(
+            dl_file = fetch_single_file(
                 url,
                 temp_dir,
                 resume=resume,
diff --git a/nilearn/datasets/func.py b/nilearn/datasets/func.py
--- a/nilearn/datasets/func.py
+++ b/nilearn/datasets/func.py
@@ -27,8 +27,8 @@
 from .._utils import check_niimg, fill_doc
 from .._utils.numpy_conversions import csv_to_array
 from ._utils import (
-    fetch_file,
     fetch_files,
+    fetch_single_file,
     filter_columns,
     get_dataset_descr,
     get_dataset_dir,
@@ -763,7 +763,7 @@ def fetch_localizer_contrasts(
     data_dir = get_dataset_dir(
         dataset_name, data_dir=data_dir, verbose=verbose
     )
-    index_file = fetch_file(index_url, data_dir, verbose=verbose)
+    index_file = fetch_single_file(index_url, data_dir, verbose=verbose)
     with open(index_file) as of:
         index = json.load(of)
 
@@ -2565,7 +2565,7 @@ def _download_spm_auditory_data(data_dir, subject_dir, subject_id):
         "MoAEpilot.zip"
     )
     archive_path = os.path.join(subject_dir, os.path.basename(url))
-    fetch_file(url, subject_dir)
+    fetch_single_file(url, subject_dir)
     try:
         uncompress_file(archive_path)
     except Exception:
@@ -2832,7 +2832,7 @@ def _download_data_spm_multimodal(data_dir, subject_dir, subject_id):
 
     for url in urls:
         archive_path = os.path.join(subject_dir, os.path.basename(url))
-        fetch_file(url, subject_dir)
+        fetch_single_file(url, subject_dir)
         try:
             uncompress_file(archive_path)
         except Exception:
@@ -2979,7 +2979,7 @@ def _glob_fiac_data():
     url = "https://nipy.org/data-packages/nipy-data-0.2.tar.gz"
 
     archive_path = os.path.join(data_dir, os.path.basename(url))
-    fetch_file(url, data_dir)
+    fetch_single_file(url, data_dir)
     try:
         uncompress_file(archive_path)
     except Exception:
diff --git a/nilearn/datasets/neurovault.py b/nilearn/datasets/neurovault.py
--- a/nilearn/datasets/neurovault.py
+++ b/nilearn/datasets/neurovault.py
@@ -22,7 +22,7 @@
 from sklearn.utils import Bunch
 
 from ..image import resample_img
-from ._utils import fetch_file, get_dataset_descr, get_dataset_dir
+from ._utils import fetch_single_file, get_dataset_descr, get_dataset_dir
 
 _NEUROVAULT_BASE_URL = "https://neurovault.org/api/"
 _NEUROVAULT_COLLECTIONS_URL = urljoin(_NEUROVAULT_BASE_URL, "collections/")
@@ -1128,7 +1128,7 @@ def _yield_from_url_list(url_list, verbose=3):
 
 
 def _simple_download(url, target_file, temp_dir, verbose=3):
-    """Wrap around ``utils.fetch_file``.
+    """Wrap around ``utils.fetch_single_file``.
 
     This allows specifying the target file name.
 
@@ -1141,7 +1141,7 @@ def _simple_download(url, target_file, temp_dir, verbose=3):
         Location of the downloaded file on filesystem.
 
     temp_dir : str
-        Location of sandbox directory used by ``fetch_file``.
+        Location of sandbox directory used by ``fetch_single_file``.
 
     verbose : int, default=3
         An integer in [0, 1, 2, 3] to control the verbosity level.
@@ -1158,12 +1158,12 @@ def _simple_download(url, target_file, temp_dir, verbose=3):
 
     See Also
     --------
-    nilearn.datasets._utils.fetch_file
+    nilearn.datasets._utils.fetch_single_file
 
     """
     _print_if(f"Downloading file: {url}", _DEBUG, verbose)
     try:
-        downloaded = fetch_file(
+        downloaded = fetch_single_file(
             url, temp_dir, resume=False, overwrite=True, verbose=0
         )
     except Exception:


Test patch:
diff --git a/nilearn/datasets/tests/test_utils.py b/nilearn/datasets/tests/test_utils.py
--- a/nilearn/datasets/tests/test_utils.py
+++ b/nilearn/datasets/tests/test_utils.py
@@ -395,7 +395,7 @@ def test_fetch_file_overwrite(
         tmp_path = str(tmp_path)
 
     # overwrite non-exiting file.
-    fil = _utils.fetch_file(
+    fil = _utils.fetch_single_file(
         url="http://foo/", data_dir=str(tmp_path), verbose=0, overwrite=True
     )
 
@@ -409,7 +409,7 @@ def test_fetch_file_overwrite(
         fp.write("some content")
 
     # Don't overwrite existing file.
-    fil = _utils.fetch_file(
+    fil = _utils.fetch_single_file(
         url="http://foo/", data_dir=str(tmp_path), verbose=0, overwrite=False
     )
 
@@ -419,7 +419,7 @@ def test_fetch_file_overwrite(
         assert fp.read() == "some content"
 
     # Overwrite existing file.
-    fil = _utils.fetch_file(
+    fil = _utils.fetch_single_file(
         url="http://foo/", data_dir=str(tmp_path), verbose=0, overwrite=True
     )