BIDS App Bootstrapping#

Tools to generate a Snakemake-based BIDS app.

This legacy module once had the core snakebids bidsapp implementation, but now is a simple wrapper around snakebids.bidsapp with the SnakemakeBidsApp plugin. For new apps, this functionality can be more flexibly implemented with:

from snakebids import bidsapp, plugins

bidsapp.app([plugins.SnakemakeBidsApp(...)])
class snakebids.app.SnakeBidsApp(snakemake_dir, plugins=_Nothing.NOTHING, skip_parse_args=False, parser=None, configfile_path=None, snakefile_path=None, config=None, version=None, args=None)#

Snakebids app with config and arguments.

Parameters:
  • snakemake_dir (str | Path) – Root directory of the snakebids app, containing the config file and workflow files.

  • plugins (list[Callable[[snakebids.app.SnakeBidsApp], None | snakebids.app.SnakeBidsApp]]) –

    List of plugins to be registered.

    See Using plugins for more info.

  • skip_parse_args (bool) – DEPRECATED: no-op.

  • parser (Any) – DEPRECATED: no-op. (Historic: Parser including only the arguments specific to this Snakebids app, as specified in the config file. By default, it will use create_parser() from cli.py)

  • configfile_path (pathlib.Path | None) – Relative path to config file (relative to snakemake_dir). By default, autocalculates based on snamake_dir

  • snakefile_path (pathlib.Path | None) –

    Absolute path to the input Snakefile. By default, autocalculates based on snakemake_dir:

    join(snakemake_dir, snakefile_path)
    

  • config (Any) – DEPRECATED: no-op. (Historic: Contains all the configuration variables parsed from the config file and generated during the initialization of the SnakeBidsApp.)

  • args (Any) – DEPRECATED: no-op. (Historic: Arguments to use when running the app. By default, generated using the parser attribute, autopopulated with args from config.py)

  • version (str | None) – DEPRECATED: no-op, use version plugin instead

property config#

Get config dict (before arguments are parsed).

property parser#

Get parser.

run_snakemake()#

Run snakemake with the given config, after applying plugins.

Return type:

None

create_descriptor(out_file)#

Generate a boutiques descriptor for this Snakebids app.

Parameters:

out_file (PathLike[str] | str) –

Return type:

None

BIDS App#

snakebids.bidsapp.app(plugins=None, *, config=None, **argparse_args)#

Create a BIDSApp.

Parameters:
  • plugins (Iterable[_Plugin] | None) – List of snakebids plugins to apply to app (see Using plugins).

  • config (dict[str, Any] | None) – Initial config. Will be updated with parsed arguments from parser and potentially modified by plugins

  • **argparse_args (Unpack[ArgumentParserArgs]) – Arguments passed on transparently to argparse.ArgumentParser.

Return type:

_Runner

class snakebids.bidsapp.run._Runner#

Runtime manager for BIDS apps.

Manages the parser, config, and plugin relay for snakebids BIDS apps. This class should not be constructed directly, but built using the bidsapp.app() function.

Parameters:
pm: pluggy.PluginManager#

Reference to the plugin manager.

parser: argparse.ArgumentParser#

Parser used for parsing CLI arguments.

The parser may be manipulated before running action methods to add initial arguments (via parser.add_argument()) and argument groups (via parser.add_argument_group()). Any argument groups added will automatically be indexed in argument_groups and made available to plugins via their title.

config: dict[str, Any]#

Configuration dictionary for passing data between plugins.

argument_groups: ArgumentGroups#

Argument group reference accessible to plugins for organizing CLI arguments.

Any groups added to the parser before the action methods are called will be automatically added, indexed by their titles. Thus, this object should typically only be used within plugins.

Action Methods#

Plugins are only run when calling the action methods. These methods trigger running of the plugins up to a specified point. For example, build_parser() runs the initialize_config() and add_cli_arguments() hooks. It can thus be used to build the parser without actually parsing any arguments.

Plugins are always run in the same order. Action methods will always trigger the entire plugin chain up until their stopping point. Importantly, plugins will only ever be run once, even if action methods are called multiple times. For example, if build_parser() is called, then parse_args(), the parser will only be built once.

build_parser()#

Run plugins affecting the parser without yet parsing arguments.

parse_args(args=None)#

Run all plugins and parse arguments.

Parameters:

args (list[str] | None) –

run(args=None)#
Parameters:

args (list[str] | None) –