Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔧 Add fail_fast to expose Nipype's stop_on_first_crash #1816

Merged
merged 2 commits into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added the ability to use TotalReadoutTime of epi field maps in the calculation of FSL topup distortion correction.
- Difference method (``-``) for ``CPAC.utils.configuration.Configuration`` instances
- Calculate reho and alff when timeseries in template space
- Added ``fail_fast`` configuration setting and CLI flag

### Changed
- Added a level of depth to `working` directories to match `log` and `output` directory structure
Expand Down
6 changes: 3 additions & 3 deletions CPAC/pipeline/cpac_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,9 @@ def run_workflow(sub_dict, c, run, pipeline_timing_info=None, p_name=None,
},
'execution': {
'crashfile_format': 'txt',
'resource_monitor_frequency': 0.2
}
})
'resource_monitor_frequency': 0.2,
'stop_on_first_crash': c['pipeline_setup', 'system_config',
'fail_fast']}})

config.enable_resource_monitor()
logging.update_logging(config)
Expand Down
1 change: 1 addition & 0 deletions CPAC/pipeline/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ def sanitize(filename):
'path': Maybe(str),
},
'system_config': {
'fail_fast': bool1_1,
'FSLDIR': Maybe(str),
'on_grid': {
'run': bool1_1,
Expand Down
6 changes: 4 additions & 2 deletions CPAC/resources/configs/pipeline_config_blank.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ pipeline_setup:

system_config:

# Stop worklow execution on first crash?
fail_fast: Off

# Random seed used to fix the state of execution.
# If unset, each process uses its own default.
# If set, a `random.log` file will be generated logging the random seed and each node to which that seed was applied.
Expand Down Expand Up @@ -1191,8 +1194,7 @@ functional_preproc:
# this is a fork point
# run: [On, Off] - this will run both and fork the pipeline
run: [Off]

space: 'native'
space: native

nuisance_corrections:
2-nuisance_regression:
Expand Down
3 changes: 2 additions & 1 deletion CPAC/resources/configs/pipeline_config_default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ pipeline_setup:
path: /outputs/crash

system_config:

# Stop worklow execution on first crash?
fail_fast: Off
# Random seed used to fix the state of execution.
# If unset, each process uses its own default.
# If set, a `random.log` file will be generated logging the random seed and each node to which that seed was applied.
Expand Down
5 changes: 4 additions & 1 deletion CPAC/resources/configs/pipeline_config_rbc-options.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ pipeline_setup:

system_config:

# Stop worklow execution on first crash?
fail_fast: On

# Random seed used to fix the state of execution.
# If unset, each process uses its own default.
# If set, a `random.log` file will be generated logging the random seed and each node to which that seed was applied.
Expand Down Expand Up @@ -110,7 +113,7 @@ functional_preproc:
# this is a fork point
# run: [On, Off] - this will run both and fork the pipeline
run: [On]
space: 'template'
space: template

nuisance_corrections:
2-nuisance_regression:
Expand Down
7 changes: 7 additions & 0 deletions dev/docker_data/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from CPAC import license_notice, __version__
from CPAC.pipeline import AVAILABLE_PIPELINE_CONFIGS
from CPAC.pipeline.random_state import set_up_random_state
from CPAC.pipeline.schema import str_to_bool1_1
from CPAC.utils.bids_utils import create_cpac_data_config, \
load_cpac_data_config, \
load_yaml_config, \
Expand Down Expand Up @@ -248,6 +249,8 @@ def run_main():
help='Save the contents of the working directory.',
default=False)

parser.add_argument('--fail_fast', type=str.title,
help='Stop worklow execution on first crash?')
parser.add_argument('--participant_label',
help='The label of the participant that should be '
'analyzed. The label corresponds to '
Expand Down Expand Up @@ -604,6 +607,10 @@ def run_main():
'Either change the output directory to something '
'local or turn off the --save_working_dir flag')

if args.fail_fast is not None:
c['pipeline_setup', 'system_config',
'fail_fast'] = str_to_bool1_1(args.fail_fast)

if c['pipeline_setup']['output_directory']['quality_control'][
'generate_xcpqc_files']:
c['functional_preproc']['motion_estimates_and_correction'][
Expand Down