Skip to content

Commit

Permalink
6728 enhance bundle config docs (#6939)
Browse files Browse the repository at this point in the history
Fixes #6728



### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Wenqi Li <[email protected]>
  • Loading branch information
wyli authored Sep 4, 2023
1 parent d876c3f commit 02e7b79
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/source/config_syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ where `#` indicates a sub-structure of this configuration file.

_Description:_ `1` is referencing as an integer, which is used to index (zero-based indexing) the `preprocessing` sub-structure.

Relative reference is supported by starting the reference with `#`. For example, `@#A` is to use `A` at the
same config structure level, and `@##A` refers to `A` at one level above.

### To evaluate as Python expressions

```json
Expand All @@ -110,6 +113,12 @@ _Description:_ `$` followed by an import statement is handled slightly different
Python expressions. The imported module `resnet18` will be available as a global variable
to the other configuration sections. This is to simplify the use of external modules in the configuration.

The config expressions may use `@` to reference other config items. For example, in `$lambda x: x + @a + @b`,
`@a` and `@b` are references to other Python objects and are made available to the anonymous function
as 'globals'.
It's therefore possible to modify the Python objects within an expression, for example,
`$lambda x: @my_list.pop() + x` will pop the last element from `@my_list` and add it to `x`.

### To textually replace configuration elements

```json
Expand Down Expand Up @@ -196,3 +205,4 @@ Details on the CLI argument parsing is provided in the
the `<module>` if it is not a (optional) dependency of MONAI.
- As "#" and "$" might be interpreted differently by the `shell` or `CLI` tools, may need to add escape characters
or quotes for them in the command line, like: `"\$torch.device('cuda:1')"`, `"'train_part#trainer'"`.
- For more details and examples, please see [the tutorials](https://github.com/Project-MONAI/tutorials/tree/main/bundle).

0 comments on commit 02e7b79

Please sign in to comment.