Skip to content

Commit 7486be5

Browse files
authored
🔊 Verbose debugging update (#1883)
2 parents 0ff4c44 + 960305c commit 7486be5

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2727
- Added `fail_fast` configuration setting and CLI flag
2828
- Added abililty to fork on motion filter
2929
- Added [`sdcflows`](https://www.nipreps.org/sdcflows/2.0/) to CPAC requirements
30+
- Added NodeBlock information to `pypeline.log` when verbose debugging is on
3031
- Added the ability to ingress FreeSurfer data into CPAC
3132
- Added the ability to toggle FreeSurfer derived masks for brain extraction
3233

CPAC/pipeline/cpac_pipeline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,6 @@ def run_workflow(sub_dict, c, run, pipeline_timing_info=None, p_name=None,
290290
'resource_monitor_frequency': 0.2,
291291
'stop_on_first_crash': c['pipeline_setup', 'system_config',
292292
'fail_fast']}})
293-
294293
config.enable_resource_monitor()
295294
logging.update_logging(config)
296295

@@ -1093,7 +1092,8 @@ def connect_pipeline(wf, cfg, rpool, pipeline_blocks):
10931092
previous_nb = None
10941093
for block in pipeline_blocks:
10951094
try:
1096-
nb = NodeBlock(block)
1095+
nb = NodeBlock(block, debug=cfg['pipeline_setup', 'Debugging',
1096+
'verbose'])
10971097
wf = nb.connect_block(wf, cfg, rpool)
10981098
except LookupError as e:
10991099
if nb.name == 'freesurfer_postproc':

CPAC/pipeline/engine.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
from CPAC.pipeline import \
2828
nipype_pipeline_engine as pe # pylint: disable=ungrouped-imports
29+
from nipype import config, logging # pylint: disable=wrong-import-order
2930
from nipype.interfaces.utility import \
3031
Rename # pylint: disable=wrong-import-order
3132
from CPAC.func_preproc.func_preproc import motion_estimate_filter
@@ -1188,8 +1189,7 @@ def node_data(self, resource, **kwargs):
11881189

11891190

11901191
class NodeBlock:
1191-
def __init__(self, node_block_functions):
1192-
1192+
def __init__(self, node_block_functions, debug=False):
11931193
if not isinstance(node_block_functions, list):
11941194
node_block_functions = [node_block_functions]
11951195

@@ -1238,6 +1238,19 @@ def __init__(self, node_block_functions):
12381238
if 'options' in init_dct:
12391239
self.options = init_dct['options']
12401240

1241+
logger.info('Connecting %s...', name)
1242+
if debug:
1243+
config.update_config(
1244+
{'logging': {'workflow_level': 'DEBUG'}})
1245+
logging.update_logging(config)
1246+
logger.debug('"inputs": %s\n\t "outputs": %s%s',
1247+
init_dct["inputs"], list(self.outputs.keys()),
1248+
f'\n\t"options": {self.options}'
1249+
if self.options != ['base'] else '')
1250+
config.update_config(
1251+
{'logging': {'workflow_level': 'INFO'}})
1252+
logging.update_logging(config)
1253+
12411254
def get_name(self):
12421255
return self.name
12431256

@@ -1384,7 +1397,6 @@ def connect_block(self, wf, cfg, rpool):
13841397
switch = [switch]
13851398

13861399
if True in switch:
1387-
logger.info('Connecting %s...', name)
13881400
for pipe_idx, strat_pool in rpool.get_strats(
13891401
inputs, debug).items(): # strat_pool is a ResourcePool like {'desc-preproc_T1w': { 'json': info, 'data': (node, out) }, 'desc-brain_mask': etc.}
13901402
fork = False in switch # keep in mind rpool.get_strats(inputs) = {pipe_idx1: {'desc-preproc_T1w': etc.}, pipe_idx2: {..} }
@@ -2202,7 +2214,7 @@ def run_node_blocks(blocks, data_paths, cfg=None):
22022214
}
22032215

22042216
# TODO: WE HAVE TO PARSE OVER UNIQUE ID'S!!!
2205-
rpool = initiate_rpool(cfg, data_paths)
2217+
_, rpool = initiate_rpool(cfg, data_paths)
22062218

22072219
wf = pe.Workflow(name='node_blocks')
22082220
wf.base_dir = cfg.pipeline_setup['working_directory']['path']
@@ -2222,7 +2234,9 @@ def run_node_blocks(blocks, data_paths, cfg=None):
22222234
run_blocks += blocks[1]
22232235

22242236
for block in run_blocks:
2225-
wf = NodeBlock(block).connect_block(wf, cfg, rpool)
2237+
wf = NodeBlock(block, debug=cfg['pipeline_setup', 'Debugging',
2238+
'verbose']).connect_block(
2239+
wf, cfg, rpool)
22262240
rpool.gather_pipes(wf, cfg)
22272241

22282242
wf.run()

0 commit comments

Comments
 (0)