Repository: mne-tools/mne-bids-pipeline

Issue:
Deploy separate documentation for (tagged) releases and development version
https://squidfunk.github.io/mkdocs-material/setup/setting-up-versioning/


Discussion:

Resolving patch:
diff --git a/docs/source/examples/gen_examples.py b/docs/source/examples/gen_examples.py
--- a/docs/source/examples/gen_examples.py
+++ b/docs/source/examples/gen_examples.py
@@ -13,6 +13,7 @@
 import mne_bids_pipeline.tests.datasets
 from mne_bids_pipeline.tests.test_run import TEST_SUITE
 from mne_bids_pipeline.tests.datasets import DATASET_OPTIONS
+from tqdm import tqdm
 
 this_dir = Path(__file__).parent
 root = Path(mne_bids_pipeline.__file__).parent.resolve(strict=True)
@@ -87,6 +88,7 @@ def _gen_demonstrated_funcs(example_config_path: Path) -> dict:
 
 # Copy reports to the correct place.
 datasets_without_html = []
+logger.warning(f'  Copying reports to {this_dir}/<dataset_name> …')
 for test_name, test_dataset_options in TEST_SUITE.items():
     if 'ERP_CORE' in test_name:
         dataset_name = test_dataset_options['dataset']
@@ -107,13 +109,25 @@ def _gen_demonstrated_funcs(example_config_path: Path) -> dict:
         datasets_without_html.append(dataset_name)
         continue
 
-    for fname in html_report_fnames:
-        logger.info(f'Copying {fname} to {example_target_dir}')
+    fname_iter = tqdm(
+        html_report_fnames,
+        desc=f'  {test_name}',
+        unit='file',
+        leave=False,
+    )
+    for fname in fname_iter:
         shutil.copy(src=fname, dst=example_target_dir)
 
 # Now, generate the respective markdown example descriptions.
 all_demonstrated = dict()
-for test_dataset_name, test_dataset_options in TEST_SUITE.items():
+logger.warning('  Generating example markdown files …')
+ds_iter = tqdm(
+    list(TEST_SUITE.items()),
+    desc='  ',
+    unit='file',
+    leave=False,
+)
+for test_dataset_name, test_dataset_options in ds_iter:
     if 'ERP_CORE' in test_dataset_name:
         dataset_name = test_dataset_options['dataset']
     else:
@@ -133,8 +147,6 @@ def _gen_demonstrated_funcs(example_config_path: Path) -> dict:
         logger.warning(f'Dataset {dataset_name} has no HTML report.')
         continue
 
-    logger.warning(f'Generating markdown file for dataset: {dataset_name}')
-
     options = DATASET_OPTIONS[dataset_options_key]
 
     report_str = '\n## Generated output\n\n'
diff --git a/mne_bids_pipeline/_report.py b/mne_bids_pipeline/_report.py
--- a/mne_bids_pipeline/_report.py
+++ b/mne_bids_pipeline/_report.py
@@ -1,4 +1,6 @@
 import contextlib
+from functools import lru_cache
+from io import StringIO
 import os.path as op
 from pathlib import Path
 from typing import Optional, List, Literal
@@ -492,9 +494,10 @@ def _finalize(
         title=titles[0],
         tags=('configuration',),
     )
-    report.add_sys_info(
-        title=titles[1],
-    )
+    # We don't use report.add_sys_info so we can use our own cached version
+    tags = ('mne-sysinfo',)
+    info = _cached_sys_info()
+    report.add_code(code=info, title=titles[1], language='shell', tags=tags)
     # Make our code sections take 50% of screen height
     css = """
 div.accordion-body pre.my-0 code {
@@ -506,6 +509,15 @@ def _finalize(
         report.add_custom_css(css=css)
 
 
+# We make a lot of calls to this function and it takes > 1 sec generally
+# to run, so run it just once (it shouldn't meaningfully change anyway)
+@lru_cache(maxsize=1)
+def _cached_sys_info(f):
+    with StringIO() as f:
+        mne.sys_info(f)
+        return f.getvalue()
+
+
 def _all_conditions(*, cfg):
     if isinstance(cfg.conditions, dict):
         conditions = list(cfg.conditions.keys())
@@ -578,6 +590,14 @@ def run_report_average_sensor(
         #
         # Visualize evoked responses.
         #
+        if all_evokeds:
+            msg = (
+                f'Adding {len(all_evokeds)} evoked signals and contrasts to '
+                'the report.'
+            )
+        else:
+            msg = 'No evoked conditions or contrasts found.'
+        logger.info(**gen_log_kwargs(message=msg))
         for condition, evoked in all_evokeds.items():
             tags = ('evoked', _sanitize_cond_tag(condition))
             if condition in cfg.conditions:
@@ -602,11 +622,15 @@ def run_report_average_sensor(
         # Visualize decoding results.
         #
         if cfg.decode and cfg.decoding_contrasts:
+            msg = 'Adding decoding results.'
+            logger.info(**gen_log_kwargs(message=msg))
             add_decoding_grand_average(
                 session=session, cfg=cfg, report=report
             )
 
         if cfg.decode and cfg.decoding_csp:
+            # No need for a separate message here because these are very quick
+            # and the general message above is sufficient
             add_csp_grand_average(
                 session=session, cfg=cfg, report=report
             )


Test patch:
diff --git a/mne_bids_pipeline/tests/conftest.py b/mne_bids_pipeline/tests/conftest.py
--- a/mne_bids_pipeline/tests/conftest.py
+++ b/mne_bids_pipeline/tests/conftest.py
@@ -25,6 +25,7 @@ def pytest_configure(config):
     ignore:subprocess .* is still running:ResourceWarning
     ignore:`np.MachAr` is deprecated.*:DeprecationWarning
     ignore:The get_cmap function will be deprecated.*:
+    ignore:make_current is deprecated.*:DeprecationWarning
     """
     for warning_line in warning_lines.split('\n'):
         warning_line = warning_line.strip()