From a75e06790705e91b72f2a2ba0b5f46fb58b5c1d8 Mon Sep 17 00:00:00 2001 From: Jason Kai Date: Sat, 24 Feb 2024 10:08:22 -0500 Subject: [PATCH] Update run.py and config for snakebids 0.12.x - Remove standard bids-app options from config (no longer necessary) - Refactor run.py to work with new version --- docs/usage/cli.md | 7 ++++--- scattr/config/snakebids.yml | 31 ------------------------------- scattr/run.py | 21 +++++++++++---------- 3 files changed, 15 insertions(+), 44 deletions(-) diff --git a/docs/usage/cli.md b/docs/usage/cli.md index 134b2bb5..4b27ec7b 100644 --- a/docs/usage/cli.md +++ b/docs/usage/cli.md @@ -9,8 +9,9 @@ cases, only the required arguments are needed. ```{argparse} --- -filename: ../scattr/run.py -func: get_parser +ref: scattr.run.get_parser +#filename: ../scattr/run.py +#func: get_parser prog: scattr --- ``` @@ -34,4 +35,4 @@ module: snakemake func: get_argument_parser prog: snakemake --- -``` \ No newline at end of file +``` diff --git a/scattr/config/snakebids.yml b/scattr/config/snakebids.yml index b5b8c802..e3940dad 100644 --- a/scattr/config/snakebids.yml +++ b/scattr/config/snakebids.yml @@ -56,37 +56,6 @@ pybids_inputs_dwi: # Configuration for the command-line parameters to make available # passed on the argparse add_argument() parse_args: - #--- core BIDS-app options --- (do not modify below) ---# - bids_dir: - help: The directory with the input dataset formatted according to the - BIDS standard. - - output_dir: - help: The directory where the output files should be stored. If you are - running group level analysis, this folder should be prepopulated - with the results of the participant level analysis. - - analysis_level: - help: Level of the analysis that will be performed - choices: *analysis_levels - - --participant_label: - help: The label(s) of the participant(s) that should be analyzed. The label - corresponds to sub- from the BIDS spec (so it does - not include "sub-"). If this parameter is not provided, all subjects - will be analyzed. Multiple participants can be specified with a space - seperated list. - nargs: "+" - - --exclude_participant_label: - help: The label(s) of the participant(s) that should be excluded. The label - corresponds to sub- from the BIDS spec (so it does - not include "sub-"). If this parameter is not provided, all subjects - will be analyzed. Multiple participants can be specified with a space - sepearated list. - nargs: "+" - #-----------------------------------------------------# - #--- additional BIDS-app options --- (add in below) --# --slurm_tmpdir: help: "Flag to indicate use of SLURM temporary directory. A temporary diff --git a/scattr/run.py b/scattr/run.py index 0d15d63d..9794a819 100644 --- a/scattr/run.py +++ b/scattr/run.py @@ -1,22 +1,23 @@ #!/usr/bin/env python -import os +from pathlib import Path -from snakebids.app import SnakeBidsApp -from snakebids.cli import add_dynamic_args +from snakebids import bidsapp, plugins + +app = bidsapp.app( + [ + plugins.SnakemakeBidsApp(Path(__file__).resolve().parent), + plugins.Version(distribution="scattr"), + ] +) def get_parser(): """Exposes parser for sphinx doc generation, cwd is the docs dir""" - app = SnakeBidsApp("../scattr", skip_parse_args=True) - add_dynamic_args( - app.parser, app.config["parse_args"], app.config["pybids_inputs"] - ) - return app.parser + return app.build_parser().parser def main(): - app = SnakeBidsApp(os.path.abspath(os.path.dirname(__file__))) - app.run_snakemake() + app.run() if __name__ == "__main__":