Skip to content

Commit e0ea592

Browse files
committed
update toc
Signed-off-by: Wenqi Li <[email protected]>
1 parent 99f83ad commit e0ea592

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

docs/source/config_syntax.md

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ The main benefits are threefold:
88
- it describes workflow at a relatively high level and allows for different low-level implementations.
99
- learning paradigms at a higher level such as federated learning and AutoML can be decoupled from the component details.
1010

11+
Content:
12+
13+
- [A basic example](#a-basic-example)
14+
- [Syntax examples explained](#syntax-examples-explained)
15+
- `@` to interpolate with Python objects
16+
- `$` to evaluate as Python expressions
17+
- `_target_` to instantiate a Python object
18+
- `%` to interpolate with plain texts
19+
1120
## A basic example
1221

1322
Components as part of a workflow can be specified using `JSON` or `YAML` syntax, for example, a network architecture
@@ -62,10 +71,14 @@ or additionally, tune the input parameters then instantiate the component:
6271
BasicUNet features: (32, 32, 32, 64, 64, 64).
6372
```
6473

74+
For more details on the `ConfigParser` API, please see https://docs.monai.io/en/latest/bundle.html#config-parser.
75+
6576
## Syntax examples explained
6677

6778
A few characters and keywords are interpreted beyond the plain texts, here are examples of the syntax:
6879

80+
### `@` to interpolate with Python objects
81+
6982
```json
7083
"@preprocessing#transforms#keys"
7184
```
@@ -79,6 +92,8 @@ where `#` indicates a sub-structure of this configuration file.
7992

8093
_Description:_ `1` is interpreted as an integer, which is used to index the `preprocessing` sub-structure.
8194

95+
### `$` to evaluate as Python expressions
96+
8297
```json
8398
"$print(42)"
8499
```
@@ -91,6 +106,8 @@ _Description:_ `$` is a special character to indicate evaluating `print(42)` at
91106

92107
_Description:_ Create a list at runtime using the values in `datalist` as input.
93108

109+
### `_target_` to instantiate a Python object
110+
94111
```json
95112
{
96113
"demo_name":{
@@ -106,13 +123,6 @@ This dictionary will be instantiated as a Pytorch object at runtime.
106123
`_target_` is a required key by monai bundle syntax for the Python object name.
107124
`args1` and `args2` should be compatible with the Python object to instantiate.
108125

109-
```json
110-
"%demo_config.json#demo_net#in_channels"
111-
```
112-
113-
_Description:_ A macro to replace the current value with the texts at `demo_net#in_channels` in the
114-
`demo_config.json` file.
115-
116126
```json
117127
{
118128
"component_name": {
@@ -128,3 +138,12 @@ Python expression that will be evaluated/instantiated before `_target_` object i
128138
It is useful when the component doesn’t explicitly depends on the other ConfigItems via
129139
its arguments, but requires the dependencies to be instantiated/evaluated beforehand.
130140
`_disabled_` specifies a flag to indicate whether to skip the instantiation.
141+
142+
### `%` to interpolate with plain texts
143+
144+
```json
145+
"%demo_config.json#demo_net#in_channels"
146+
```
147+
148+
_Description:_ A macro to replace the current value with the texts at `demo_net#in_channels` in the
149+
`demo_config.json` file.

0 commit comments

Comments
 (0)