anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: nipreps/mriqc
Issue: default logging level is not used throughout all mriqc subprocesses when called by CLI

The default logging level is not used throughout all mriqc subprocesses; right now it logs info despite --verbose input defaulting to level 25 (custom state important and above, warning is 30). The nipype subprocess seems to be the issue. See logs excerpt, used mriqc version 0.15.1

[mriqc_sample_logs.txt](https://github.com/nipreps/mriqc/files/8162782/mriqc_sample_logs.txt)


Changed files:
mriqc/config.py, mriqc/engine/plugin.py, mriqc/cli/run.py

diff --git a/mriqc/cli/run.py b/mriqc/cli/run.py
index ce8f8e2f..19948af1 100644
--- a/mriqc/cli/run.py
+++ b/mriqc/cli/run.py
@@ -54,6 +54,7 @@ def main():
         dir=config.execution.work_dir, prefix=".mriqc.", suffix=".toml"
     )
     config.to_filename(config_file)
+    config.file_path = config_file
 
     # Set up participant level
     if "participant" in config.workflow.analysis_level:
@@ -73,7 +74,7 @@ def main():
             _pool = ProcessPoolExecutor(
                 max_workers=config.nipype.nprocs,
                 initializer=config._process_initializer,
-                initargs=(config.execution.cwd, config.nipype.omp_nthreads),
+                initargs=(config.file_path,),
             )
 
         _resmon = None
diff --git a/mriqc/config.py b/mriqc/config.py
index 33d33813..f5a935ef 100644
--- a/mriqc/config.py
+++ b/mriqc/config.py
@@ -200,6 +200,11 @@ try:
 except Exception:
     pass
 
+file_path: Path = None
+"""
+Path to configuration file.
+"""
+
 
 class _Config:
     """An abstract class forbidding instantiation."""
@@ -632,11 +637,28 @@ def to_filename(filename):
     filename.write_text(dumps())
 
 
-def _process_initializer(cwd, omp_nthreads):
+def _process_initializer(config_file: Path):
     """Initialize the environment of the child process."""
-    os.chdir(cwd)
+    from mriqc import config
+
+    # Disable eTelemetry
     os.environ["NIPYPE_NO_ET"] = "1"
-    os.environ["OMP_NUM_THREADS"] = f"{omp_nthreads}"
+    os.environ["NO_ET"] = "1"
+
+    # Load config
+    config.load(config_file)
+
+    # Initialize nipype config
+    config.nipype.init()
+
+    # Make sure loggers are started
+    config.loggers.init()
+
+    # Change working directory according to the config
+    os.chdir(config.execution.cwd)
+
+    # Set the maximal number of threads per process
+    os.environ["OMP_NUM_THREADS"] = f"{config.nipype.omp_nthreads}"
 
 
 def restore_env():
diff --git a/mriqc/engine/plugin.py b/mriqc/engine/plugin.py
index a41a984f..c8d9d50b 100644
--- a/mriqc/engine/plugin.py
+++ b/mriqc/engine/plugin.py
@@ -441,7 +441,7 @@ class MultiProcPlugin(DistributedPluginBase):
         self.pool = pool or ProcessPoolExecutor(
             max_workers=self.processors,
             initializer=config._process_initializer,
-            initargs=(config.execution.cwd, config.nipype.omp_nthreads),
+            initargs=(config.file_path,),
             mp_context=mp_context,
         )