Skip to content

Commit 0bb4ca7

Browse files
Updated readmes according to restructured config (#266)
* Updated readmes according to restructured config * Update proper format * Refactor readmes using merging templates * Modify Formatting * Update typo * Modify commands to be on one line * Merge branch 'main' into 'update-readmes' - Added optional attributes - train_epoch_length and eval_epoch_length have been set as optional according to engine definition * Added new line to replace, replaces the text and new line - Avoids new lines and adheres to formatting
1 parent 9393a04 commit 0bb4ca7

File tree

6 files changed

+51
-633
lines changed

6 files changed

+51
-633
lines changed

src/store.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export function saveConfig(key, value) {
6262
// merges the code from the common and specific files using ejs
6363
function mergeCode(specificFileText, commonFileText) {
6464
const replaced = specificFileText.replace(
65-
/#::= from_template_common ::#/g,
65+
/#::= from_template_common ::#\n/g,
6666
commonFileText
6767
)
6868
return replaced

src/templates/template-common/README.md

Lines changed: 46 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## Getting Started
2+
3+
Install the dependencies with `pip`:
4+
5+
```sh
6+
pip install -r requirements.txt --progress-bar off -U
7+
```
8+
19
### Code structure
210

311
#::: if (it.include_test) { :::#
@@ -11,7 +19,9 @@
1119
|- models.py : helper module with functions to create a model or multiple models
1220
|- trainers.py : helper module with functions to create trainer and evaluator
1321
|- utils.py : module with various helper functions
14-
|
22+
#::: if (it.template === 'template-vision-segmentation') { :::#
23+
|- vis.py : helper module for data visualizations
24+
#::: } :::#
1525
|- requirements.txt : dependencies to install with pip
1626
|
1727
|- config.yaml : global configuration YAML file
@@ -30,14 +40,18 @@
3040
|- models.py : helper module with functions to create a model or multiple models
3141
|- trainers.py : helper module with functions to create trainer and evaluator
3242
|- utils.py : module with various helper functions
33-
|
43+
#::: if (it.template === 'template-vision-segmentation') { :::#
44+
|- vis.py : helper module for data visualizations
45+
#::: } :::#
3446
|- requirements.txt : dependencies to install with pip
3547
|
3648
|- config.yaml : global configuration YAML file
3749
```
3850

3951
#::: } :::#
4052

53+
## Training
54+
4155
#::: if (it.use_dist) { :::#
4256
#::: if (it.dist === 'torchrun') { :::#
4357
#::: if (it.nproc_per_node) { :::#
@@ -54,8 +68,7 @@ torchrun \
5468
--node_rank 0 \
5569
--master_addr #:::= it.master_addr :::# \
5670
--master_port #:::= it.master_port :::# \
57-
main.py \
58-
--backend #:::= it.backend :::#
71+
main.py config.yaml --backend #:::= it.backend :::#
5972
```
6073

6174
- Execute on worker nodes
@@ -67,8 +80,7 @@ torchrun \
6780
--node_rank <node_rank> \
6881
--master_addr #:::= it.master_addr :::# \
6982
--master_port #:::= it.master_port :::# \
70-
main.py \
71-
--backend #:::= it.backend :::#
83+
main.py config.yaml --backend #:::= it.backend :::#
7284
```
7385

7486
#::: } else { :::#
@@ -78,8 +90,7 @@ torchrun \
7890
```sh
7991
torchrun \
8092
--nproc_per_node #:::= it.nproc_per_node :::# \
81-
main.py \
82-
--backend #:::= it.backend :::#
93+
main.py config.yaml --backend #:::= it.backend :::#
8394
```
8495

8596
#::: } :::#
@@ -94,36 +105,45 @@ torchrun \
94105

95106
- Execute on master node
96107

108+
```yaml
109+
# config.yaml
110+
nproc_per_node: #:::= it.nproc_per_node :::#
111+
nnodes: #:::= it.nnodes :::#
112+
node_rank: 0
113+
master_addr: #:::= it.master_addr :::#
114+
master_port: #:::= it.master_port :::#
115+
```
116+
97117
```sh
98-
python main.py \
99-
--nproc_per_node #:::= it.nproc_per_node :::# \
100-
--nnodes #:::= it.nnodes :::# \
101-
--node_rank 0 \
102-
--master_addr #:::= it.master_addr :::# \
103-
--master_port #:::= it.master_port :::# \
104-
--backend #:::= it.backend :::#
118+
python main.py config.yaml --backend #:::= it.backend :::#
105119
```
106120

107121
- Execute on worker nodes
108122

123+
```yaml
124+
# config.yaml
125+
nproc_per_node: #:::= it.nproc_per_node :::#
126+
nnodes: #:::= it.nnodes :::#
127+
node_rank: <node_rank>
128+
master_addr: #:::= it.master_addr :::#
129+
master_port: #:::= it.master_port :::#
130+
```
131+
109132
```sh
110-
python main.py \
111-
--nproc_per_node #:::= it.nproc_per_node :::# \
112-
--nnodes #:::= it.nnodes :::# \
113-
--node_rank <node_rank> \
114-
--master_addr #:::= it.master_addr :::# \
115-
--master_port #:::= it.master_port :::# \
116-
--backend #:::= it.backend :::#
133+
python main.py config.yaml --backend #:::= it.backend :::#
117134
```
118135

119136
#::: } else { :::#
120137

121138
### Multi GPU Training (`torch.multiprocessing.spawn`)
122139

140+
```yaml
141+
# config.yaml
142+
nproc_per_node: #:::= it.nproc_per_node :::#
143+
```
144+
123145
```sh
124-
python main.py \
125-
--nproc_per_node #:::= it.nproc_per_node :::# \
126-
--backend #:::= it.backend :::#
146+
python main.py config.yaml --backend #:::= it.backend :::#
127147
```
128148

129149
#::: } :::#
@@ -135,7 +155,7 @@ python main.py \
135155
### 1 GPU Training
136156

137157
```sh
138-
python main.py
158+
python main.py config.yaml
139159
```
140160

141161
#::: } :::#

src/templates/template-text-classification/README.md

Lines changed: 1 addition & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -4,154 +4,4 @@
44

55
This is the text classification template by Code-Generator using `bert-base-uncased` model from HuggingFace Transformers and `imdb` dataset from HuggingFace datasets and training is powered by PyTorch and PyTorch-Ignite.
66

7-
## Getting Started
8-
9-
Install the dependencies with `pip`:
10-
11-
```sh
12-
pip install -r requirements.txt --progress-bar off -U
13-
```
14-
15-
### Code structure
16-
17-
#::: if (it.include_test) { :::#
18-
19-
```
20-
|
21-
|- README.md
22-
|
23-
|- main.py : main script to run
24-
|- data.py : helper module with functions to setup input datasets and create dataloaders
25-
|- models.py : helper module with functions to create a model or multiple models
26-
|- trainers.py : helper module with functions to create trainer and evaluator
27-
|- utils.py : module with various helper functions
28-
|
29-
|- requirements.txt : dependencies to install with pip
30-
|
31-
|- config.yaml : global configuration YAML file
32-
|
33-
|- test_all.py : test file with few basic sanity checks
34-
```
35-
36-
#::: } else { :::#
37-
38-
```
39-
|
40-
|- README.md
41-
|
42-
|- main.py : main script to run
43-
|- data.py : helper module with functions to setup input datasets and create dataloaders
44-
|- models.py : helper module with functions to create a model or multiple models
45-
|- trainers.py : helper module with functions to create trainer and evaluator
46-
|- utils.py : module with various helper functions
47-
|
48-
|- requirements.txt : dependencies to install with pip
49-
|
50-
|- config.yaml : global configuration YAML file
51-
```
52-
53-
#::: } :::#
54-
55-
## Training
56-
57-
#::: if (it.use_dist) { :::#
58-
#::: if (it.dist === 'torchrun') { :::#
59-
#::: if (it.nproc_per_node) { :::#
60-
#::: if (it.nnodes > 1 && it.master_addr && it.master_port) { :::#
61-
62-
### Multi Node, Multi GPU Training (`torchrun`) (recommended)
63-
64-
- Execute on master node
65-
66-
```sh
67-
torchrun \
68-
--nproc_per_node #:::= it.nproc_per_node :::# \
69-
--nnodes #:::= it.nnodes :::# \
70-
--node_rank 0 \
71-
--master_addr #:::= it.master_addr :::# \
72-
--master_port #:::= it.master_port :::# \
73-
main.py \
74-
--backend #:::= it.backend :::#
75-
```
76-
77-
- Execute on worker nodes
78-
79-
```sh
80-
torchrun \
81-
--nproc_per_node #:::= it.nproc_per_node :::# \
82-
--nnodes #:::= it.nnodes :::# \
83-
--node_rank <node_rank> \
84-
--master_addr #:::= it.master_addr :::# \
85-
--master_port #:::= it.master_port :::# \
86-
main.py \
87-
--backend #:::= it.backend :::#
88-
```
89-
90-
#::: } else { :::#
91-
92-
### Multi GPU Training (`torchrun`) (recommended)
93-
94-
```sh
95-
torchrun \
96-
--nproc_per_node #:::= it.nproc_per_node :::# \
97-
main.py \
98-
--backend #:::= it.backend :::#
99-
```
100-
101-
#::: } :::#
102-
#::: } :::#
103-
#::: } :::#
104-
105-
#::: if (it.dist === 'spawn') { :::#
106-
#::: if (it.nproc_per_node) { :::#
107-
#::: if (it.nnodes > 1 && it.master_addr && it.master_port) { :::#
108-
109-
### Multi Node, Multi GPU Training (`torch.multiprocessing.spawn`)
110-
111-
- Execute on master node
112-
113-
```sh
114-
python main.py \
115-
--nproc_per_node #:::= it.nproc_per_node :::# \
116-
--nnodes #:::= it.nnodes :::# \
117-
--node_rank 0 \
118-
--master_addr #:::= it.master_addr :::# \
119-
--master_port #:::= it.master_port :::# \
120-
--backend #:::= it.backend :::#
121-
```
122-
123-
- Execute on worker nodes
124-
125-
```sh
126-
python main.py \
127-
--nproc_per_node #:::= it.nproc_per_node :::# \
128-
--nnodes #:::= it.nnodes :::# \
129-
--node_rank <node_rank> \
130-
--master_addr #:::= it.master_addr :::# \
131-
--master_port #:::= it.master_port :::# \
132-
--backend #:::= it.backend :::#
133-
```
134-
135-
#::: } else { :::#
136-
137-
### Multi GPU Training (`torch.multiprocessing.spawn`)
138-
139-
```sh
140-
python main.py \
141-
--nproc_per_node #:::= it.nproc_per_node :::# \
142-
--backend #:::= it.backend :::#
143-
```
144-
145-
#::: } :::#
146-
#::: } :::#
147-
#::: } :::#
148-
149-
#::: } else { :::#
150-
151-
### 1 GPU Training
152-
153-
```sh
154-
python main.py
155-
```
156-
157-
#::: } :::#
7+
#::= from_template_common ::#

0 commit comments

Comments
 (0)