You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/sphinx_doc/source/tutorial/trinity_programming_guide.md
+120Lines changed: 120 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -286,6 +286,126 @@ trinity run --config <your_yaml_file>
286
286
287
287
---
288
288
289
+
## Adding New Config Entries for the Config Generator (Advanced)
290
+
291
+
### Step 0: Understanding Streamlit
292
+
293
+
Before adding new parameters to the Config Generator page, it is essential to familiarize yourself with the relevant API and mechanisms of [Streamlit](https://docs.streamlit.io/develop/api-reference). This project primarily utilizes various input components from Streamlit and employs `st.session_state` to store user-input parameters.
294
+
295
+
### Step 1: Implement New Config Entries
296
+
297
+
To illustrate the process of creating a new parameter setting for the Config Generator page, we will use `train_batch_size` as an example.
298
+
299
+
1. Determine the appropriate scope for the parameter. Currently, parameters are categorized into four files:
In this case, `train_batch_size` should be placed in the `buffer_config_manager.py` file.
306
+
307
+
2. Create a parameter setting function using Streamlit. The function name must follow the convention of starting with 'set_', and the remainder of the name becomes the config name.
308
+
309
+
3. Decorate the parameter setting function with the `CONFIG_GENERATORS.register_config` decorator. This decorator requires the following information:
310
+
- Default value of the parameter
311
+
- Visibility condition (if applicable)
312
+
- Additional config parameters (if needed)
313
+
314
+
```{note}
315
+
The `CONFIG_GENERATORS.register_config` decorator automatically passes `key=config_name` as an argument to the registered configuration function. Ensure that your function accepts this keyword argument.
316
+
```
317
+
318
+
For `train_batch_size`, we will use the following settings:
If the parameter requires validation, create a check function. For `train_batch_size`, we need to ensure it is divisible by `trainer_gpu_num`. If not, a warning should be displayed, and the parameter should be added to `unfinished_fields`.
355
+
356
+
Decorate the check function with the `CONFIG_GENERATORS.register_check` decorator:
if st.session_state[key] % st.session_state["trainer_gpu_num"] !=0:
362
+
unfinished_fields.add(key)
363
+
st.warning(_str_for_train_batch_size())
364
+
```
365
+
366
+
```{note}
367
+
The `CONFIG_GENERATORS.register_check` decorator automatically receives `key=config_name` and `unfinished_fields=self.unfinished_fields` as arguments. Ensure your function accepts these keyword arguments.
368
+
```
369
+
370
+
### Step 2: Integrating New Parameters into `config_manager.py`
371
+
372
+
To successfully integrate new parameters into the `config_manager.py` file, please adhere to the following procedure:
373
+
374
+
1. Parameter Categorization:
375
+
Determine the appropriate section for the new parameter based on its functionality. The config generator page is structured into two primary modes:
376
+
- Beginner Mode: Comprises "Essential Configs" and "Important Configs" sections.
377
+
- Expert Mode: Includes "Model", "Buffer", "Explorer and Synchronizer", and "Trainer" sections.
378
+
379
+
2. Parameter Addition:
380
+
Incorporate the new parameter into the relevant section using the `self.get_configs` method within the `ConfigManager` class.
Locate the appropriate position for the new parameter within the YAML file structure. This should be done in the `generate_config` function and its associated sub-functions.
391
+
392
+
4. Parameter Value Assignment:
393
+
Utilize `st.session_state` to retrieve the parameter value from the config generator page and assign it to the corresponding field in the YAML.
By meticulously following these steps, you can ensure that new parameters are successfully added to the Config Generator page and properly integrated into the configuration system. This process maintains the integrity and functionality of the configuration management framework.
406
+
407
+
---
408
+
289
409
## Check Code Style
290
410
291
411
Before submitting the code, make sure it passes the code style check. Follow these steps:
0 commit comments