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

ENH: Reuse config #2240

Merged
merged 5 commits into from
Aug 31, 2020
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
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -653,10 +653,10 @@ jobs:
- run:
name: Generate report with one artificial error
command: |
set -x
sudo mv /tmp/${DATASET}/derivatives/fmriprep/sub-100185.html \
/tmp/${DATASET}/derivatives/fmriprep/sub-100185_noerror.html
UUID="$(date '+%Y%m%d-%H%M%S_')$(uuidgen)"
mkdir -p /tmp/${DATASET}/derivatives/fmriprep/sub-100185/log/$UUID/
UUID=$(grep uuid /tmp/${DATASET}/work/*/config.toml | cut -d\" -f 2)
cp /tmp/src/fmriprep/fmriprep/data/tests/crash_files/*.txt \
/tmp/${DATASET}/derivatives/fmriprep/sub-100185/log/$UUID/
set +e
Expand All @@ -666,7 +666,7 @@ jobs:
/tmp/data/${DATASET} /tmp/${DATASET}/derivatives participant \
--fs-no-reconall --sloppy --write-graph \
--output-spaces MNI152NLin2009cAsym:res-2 anat func \
--reports-only --run-uuid $UUID
--reports-only --config-file /tmp/${DATASET}/work/${UUID}/config.toml -vv
RET=$?
set -e
[[ "$RET" -eq "1" ]]
Expand Down
16 changes: 11 additions & 5 deletions fmriprep/cli/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ def _bids_filter(value):
)
g_conf.add_argument(
"--random-seed",
dest="_random_seed",
action="store",
type=int,
default=None,
Expand Down Expand Up @@ -505,12 +506,11 @@ def _bids_filter(value):
"aggregation, not reportlet generation for specific nodes.",
)
g_other.add_argument(
"--run-uuid",
"--config-file",
action="store",
default=None,
help="Specify UUID of previous run, to include error logs in report. "
"No effect without --reports-only.",
)
metavar="FILE",
help="Use pre-generated configuration file. Values in file will be overridden "
"by command-line arguments.")
g_other.add_argument(
"--write-graph",
action="store_true",
Expand Down Expand Up @@ -575,6 +575,12 @@ def parse_args(args=None, namespace=None):

parser = _build_parser()
opts = parser.parse_args(args, namespace)

if opts.config_file:
skip = {} if opts.reports_only else {"execution": ("run_uuid",)}
config.load(opts.config_file, skip=skip)
config.loggers.cli.info(f"Loaded previous configuration file {opts.config_file}")

config.execution.log_level = int(max(25 - 5 * opts.verbose_count, logging.DEBUG))
config.from_dict(vars(opts))

Expand Down
Loading