Skip to content

Commit

Permalink
Clean docs and clarify Path type for cli
Browse files Browse the repository at this point in the history
Remove discussion of fully resolved module paths (still technically
possible but not super relevant) and clarify how Path should be used for
all paths to avoid relative path issues
  • Loading branch information
pvandyken committed Jan 12, 2024
1 parent 6fe44f1 commit fde43dd
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions docs/bids_app/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,16 @@ A mapping from the name of each ``analysis_level`` to the list of rules or files

A dictionary of command-line parameters to make available as part of the BIDS app. Each item of the mapping is passed to [argparse's `add_argument` function](#argparse.ArgumentParser.add_argument). A number of default entries are present in a new snakebids project's config file that structure the BIDS app's CLI, but additional command-line arguments can be added as necessary.

As in [`ArgumentParser.add_argument()`](#argparse.ArgumentParser.add_argument), `type` may be used to convert the argument to the specified type. It may be set to any builtin type, or the fully resolved path of a derived type. [`Path`](#pathlib.Path) may also be used directly:
As in [`ArgumentParser.add_argument()`](#argparse.ArgumentParser.add_argument), `type` may be used to convert the argument to the specified type. It may be set to any type that can be serialized into yaml, for instance, `str`, `int`, `float`, and `boolean`.

```yaml
parse_args:
--a-string:
help: args are string by default
--a-path:
help: A path pointing to data needed for the pipeline
help: |
A path pointing to data needed for the pipeline. These are still converted
into strings, but are first resolved into absolute paths (see below)
type: Path
--another-path:
help: This type annotation does the same thing as above
Expand All @@ -96,9 +100,7 @@ parse_args:
type: float
```

```{note}
For object resolution to work, the last component of the module (i.e. following the final `.`) must be the name of a type, and all preceding components must be module and submodule names. So for instance, one cannot access a class method using this syntax.
```
When CLI parameters are used to collect paths, `type` should be set to [`Path`](#pathlib.Path) (or [`pathlib.Path`](#pathlib.Path)). These arguments will still be serialized as strings (since yaml doesn't have a path type), but snakebids will automatically resolve all arguments into absolute paths. This is important to prevent issues with snakebids and relative paths.


### `debug`
Expand Down

0 comments on commit fde43dd

Please sign in to comment.