From 3af3b8a201cbef47e4780093c58936f6e39069ea Mon Sep 17 00:00:00 2001
From: sfmig <33267254+sfmig@users.noreply.github.com>
Date: Thu, 5 Oct 2023 11:05:10 +0100
Subject: [PATCH] rename json factory function

---
 .../cellfinder/cellfinder_main.py             | 33 +++++++++++++++----
 .../test_cellfinder_workflow.py               |  4 +--
 2 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/brainglobe_workflows/cellfinder/cellfinder_main.py b/brainglobe_workflows/cellfinder/cellfinder_main.py
index acea6498..c411ac38 100644
--- a/brainglobe_workflows/cellfinder/cellfinder_main.py
+++ b/brainglobe_workflows/cellfinder/cellfinder_main.py
@@ -32,21 +32,38 @@
 CELLFINDER_CACHE_DIR = Path.home() / ".cellfinder_workflows"
 
 
-def default_config_dict(CELLFINDER_CACHE_DIR):
+def make_default_config_dict(cellfinder_cache_dir):
+    """Generate a config dictionary with the required parameters
+    for the workflow
+
+    The input data is fetched from GIN and downloaded to
+    the location provided by cellfinder_cache_dir. The results are
+    also saved in a timestamped output subdirectory under cellfinder_cache_dir
+
+    Parameters
+    ----------
+    cellfinder_cache_dir : _type_
+        _description_
+
+    Returns
+    -------
+    dict
+        dictionary with the required parameters for the workflow
+    """
     return {
-        "install_path": CELLFINDER_CACHE_DIR,
+        "install_path": cellfinder_cache_dir,
         "data_url": "https://gin.g-node.org/BrainGlobe/test-data/raw/master/cellfinder/cellfinder-test-data.zip",
         "data_hash": (
             "b0ef53b1530e4fa3128fcc0a752d0751909eab129d701f384fc0ea5f138c5914"
         ),
-        "local_path": CELLFINDER_CACHE_DIR / "cellfinder_test_data",
+        "local_path": cellfinder_cache_dir / "cellfinder_test_data",
         "signal_parent_dir": str(
-            CELLFINDER_CACHE_DIR / "cellfinder_test_data" / "signal"
+            cellfinder_cache_dir / "cellfinder_test_data" / "signal"
         ),
         "background_parent_dir": str(
-            CELLFINDER_CACHE_DIR / "cellfinder_test_data" / "background"
+            cellfinder_cache_dir / "cellfinder_test_data" / "background"
         ),
-        "output_path_basename": CELLFINDER_CACHE_DIR / "cellfinder_output_",
+        "output_path_basename": cellfinder_cache_dir / "cellfinder_output_",
         "detected_cells_filename": "detected_cells.xml",
         "voxel_sizes": [5, 2, 2],  # microns
         "start_plane": 0,
@@ -203,7 +220,9 @@ def setup_workflow(cellfinder_cache_dir=CELLFINDER_CACHE_DIR):
         )
     # else use the default config, with the cellfinder cache directory provided
     else:
-        config = CellfinderConfig(**default_config_dict(cellfinder_cache_dir))
+        config = CellfinderConfig(
+            **make_default_config_dict(cellfinder_cache_dir)
+        )
         logger.info("Using default configuration")
 
     # Retrieve and add lists of input data to config if neither are defined
diff --git a/tests/test_integration/test_cellfinder_workflow.py b/tests/test_integration/test_cellfinder_workflow.py
index a4128fd7..48c8f0b6 100644
--- a/tests/test_integration/test_cellfinder_workflow.py
+++ b/tests/test_integration/test_cellfinder_workflow.py
@@ -6,7 +6,7 @@
 import pytest
 
 from brainglobe_workflows.cellfinder.cellfinder_main import (
-    default_config_dict,
+    make_default_config_dict,
     run_workflow_from_cellfinder_run,
     setup_workflow,
 )
@@ -42,7 +42,7 @@ def prep_json(obj):
     # alter config if required by the test
     # - missing signal directory
     # - missing background directory
-    config_dict = default_config_dict(cellfinder_cache_dir)
+    config_dict = make_default_config_dict(cellfinder_cache_dir)
 
     # dump config into json
     with open(input_config_path, "w") as js: