Skip to content

Commit c081ac7

Browse files
Updated UI for ArgParser options in TrainingTab.vue (#298)
* Updated UI for ArgParser options in TrainingTab.vue * Introduce CI changes for argparse UI option * Remove bug in tests --------- Co-authored-by: vfdev <vfdev.5@gmail.com>
1 parent 03b8d17 commit c081ac7

File tree

12 files changed

+759
-669
lines changed

12 files changed

+759
-669
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,14 @@ jobs:
8080
pip install tqdm
8181
8282
- run: pnpm build
83-
- run: pnpm test:ci
83+
84+
- name: 'pnpm test:ci ${{ matrix.template }}'
85+
env:
86+
NPM_CONFIG: ${{ matrix.template }}
87+
run: pnpm test:ci
88+
8489
- run: sh ./scripts/run_tests.sh unzip
85-
- run: pnpm dist_lint
90+
- run: pnpm dist_lint ${{ matrix.template }}
8691

8792
- name: 'Run ${{ matrix.template }} ${{ matrix.test }}'
8893
run: sh ./scripts/run_tests.sh ${{ matrix.test }} ${{ matrix.template }}

__tests__/text-classification.spec.js

Lines changed: 178 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -24,169 +24,181 @@ afterEach(async () => {
2424
await context.close()
2525
})
2626

27-
test('text classification simple', async () => {
28-
await page.selectOption('select', 'template-text-classification')
29-
30-
await page.waitForSelector('text=README.md')
31-
32-
await page.click('text=Loggers')
33-
await page.click('text=config.yaml')
34-
35-
// TODO: simplify the downloadPromise calls
36-
// Here we are trying to wait for 2 seconds before clicking on the `Code` and `Download Zip` button
37-
const downloadPromise = await page
38-
.waitForEvent('download', { timeout: 2000 })
39-
.catch(() => {
40-
page.getByRole('button', { name: 'Code' }).click()
41-
page.getByRole('button', { name: 'Download Zip' }).click()
42-
return page.waitForEvent('download', { timeout: 2000 })
43-
})
44-
.catch(() => {
45-
// these catch calls are required to make sure if CI fails initially then we can have something to rely for further tests
46-
page.getByRole('button', { name: 'Code' }).click()
47-
page.getByRole('button', { name: 'Download Zip' }).click()
48-
return page.waitForEvent('download', { timeout: 2000 })
49-
})
50-
.catch(() => {
51-
page.getByRole('button', { name: 'Code' }).click()
52-
page.getByRole('button', { name: 'Download Zip' }).click()
53-
return page.waitForEvent('download', { timeout: 2000 })
54-
})
55-
56-
await downloadPromise.saveAs('./dist-tests/text-classification-simple.zip')
57-
})
58-
59-
test('text classification all', async () => {
60-
await page.selectOption('select', 'template-text-classification')
61-
62-
await page.check('#include_test-checkbox')
63-
expect(await page.isChecked('#include_test-checkbox')).toBeTruthy()
64-
65-
await page.waitForSelector('text=README.md')
66-
await page.click('text=Training')
67-
68-
await page.check('#deterministic-checkbox')
69-
expect(await page.isChecked('#deterministic-checkbox')).toBeTruthy()
70-
71-
await page.click('text=Handlers')
72-
73-
await page.check('#save_training-checkbox')
74-
expect(await page.isChecked('#save_training-checkbox')).toBeTruthy()
75-
76-
await page.check('#save_evaluation-checkbox')
77-
expect(await page.isChecked('#save_evaluation-checkbox')).toBeTruthy()
78-
79-
await page.fill('#filename_prefix-input-text', 'training')
80-
expect(await page.$eval('#filename_prefix-input-text', (e) => e.value)).toBe(
81-
'training'
82-
)
83-
84-
await page.fill('#save_every_iters-input-number', '2')
85-
expect(
86-
await page.$eval('#save_every_iters-input-number', (e) => e.value)
87-
).toBe('2')
88-
89-
await page.fill('#n_saved-input-number', '2')
90-
expect(await page.$eval('#n_saved-input-number', (e) => e.value)).toBe('2')
91-
92-
await page.check('#terminate_on_nan-checkbox')
93-
expect(await page.isChecked('#terminate_on_nan-checkbox')).toBeTruthy()
94-
95-
await page.fill('#patience-input-number', '2')
96-
expect(await page.$eval('#patience-input-number', (e) => e.value)).toBe('2')
97-
98-
await page.fill('#limit_sec-input-number', '60')
99-
expect(await page.$eval('#limit_sec-input-number', (e) => e.value)).toBe('60')
100-
101-
await page.click('text=Loggers')
102-
await page.click('text=config.yaml')
103-
104-
const downloadPromise = await page
105-
.waitForEvent('download', { timeout: 2000 })
106-
.catch(() => {
107-
page.getByRole('button', { name: 'Code' }).click()
108-
page.getByRole('button', { name: 'Download Zip' }).click()
109-
return page.waitForEvent('download', { timeout: 2000 })
110-
})
111-
.catch(() => {
112-
page.getByRole('button', { name: 'Code' }).click()
113-
page.getByRole('button', { name: 'Download Zip' }).click()
114-
return page.waitForEvent('download', { timeout: 2000 })
115-
})
116-
.catch(() => {
117-
page.getByRole('button', { name: 'Code' }).click()
118-
page.getByRole('button', { name: 'Download Zip' }).click()
119-
return page.waitForEvent('download', { timeout: 2000 })
120-
})
121-
await downloadPromise.saveAs('./dist-tests/text-classification-all.zip')
122-
})
123-
124-
test('text classification launch', async () => {
125-
await page.selectOption('select', 'template-text-classification')
126-
127-
await page.waitForSelector('text=README.md')
128-
await page.click('text=Training')
129-
130-
await page.check('#use_dist-checkbox')
131-
expect(await page.isChecked('#use_dist-checkbox')).toBeTruthy()
132-
133-
expect(await page.isChecked('#dist-torchrun-radio')).toBeTruthy()
134-
135-
await page.click('text=Loggers')
136-
await page.click('text=config.yaml')
137-
138-
const downloadPromise = await page
139-
.waitForEvent('download', { timeout: 2000 })
140-
.catch(() => {
141-
page.getByRole('button', { name: 'Code' }).click()
142-
page.getByRole('button', { name: 'Download Zip' }).click()
143-
return page.waitForEvent('download', { timeout: 2000 })
144-
})
145-
.catch(() => {
146-
page.getByRole('button', { name: 'Code' }).click()
147-
page.getByRole('button', { name: 'Download Zip' }).click()
148-
return page.waitForEvent('download', { timeout: 2000 })
149-
})
150-
.catch(() => {
151-
page.getByRole('button', { name: 'Code' }).click()
152-
page.getByRole('button', { name: 'Download Zip' }).click()
153-
return page.waitForEvent('download', { timeout: 2000 })
154-
})
155-
156-
await downloadPromise.saveAs('./dist-tests/text-classification-launch.zip')
157-
})
158-
159-
test('text classification spawn', async () => {
160-
await page.selectOption('select', 'template-text-classification')
161-
162-
await page.waitForSelector('text=README.md')
163-
await page.click('text=Training')
164-
165-
await page.check('#use_dist-checkbox')
166-
expect(await page.isChecked('#use_dist-checkbox')).toBeTruthy()
167-
168-
await page.check('#dist-spawn-radio')
169-
expect(await page.isChecked('#dist-spawn-radio')).toBeTruthy()
170-
171-
await page.click('text=Loggers')
172-
await page.click('text=config.yaml')
173-
174-
const downloadPromise = await page
175-
.waitForEvent('download', { timeout: 2000 })
176-
.catch(() => {
177-
page.getByRole('button', { name: 'Code' }).click()
178-
page.getByRole('button', { name: 'Download Zip' }).click()
179-
return page.waitForEvent('download', { timeout: 2000 })
180-
})
181-
.catch(() => {
182-
page.getByRole('button', { name: 'Code' }).click()
183-
page.getByRole('button', { name: 'Download Zip' }).click()
184-
return page.waitForEvent('download', { timeout: 2000 })
185-
})
186-
.catch(() => {
187-
page.getByRole('button', { name: 'Code' }).click()
188-
page.getByRole('button', { name: 'Download Zip' }).click()
189-
return page.waitForEvent('download', { timeout: 2000 })
190-
})
191-
await downloadPromise.saveAs('./dist-tests/text-classification-spawn.zip')
192-
})
27+
const parser = ['argparse']
28+
for (const name of parser) {
29+
test(`text-classification simple ${name}`, async () => {
30+
await page.selectOption('select', 'template-text-classification')
31+
32+
await page.waitForSelector('text=README.md')
33+
34+
await page.click('text=Loggers')
35+
await page.click('text=config.yaml')
36+
await page.getByText('Training', { exact: true }).click()
37+
38+
// TODO: simplify the downloadPromise calls
39+
// Here we are trying to wait for 2 seconds before clicking on the `Code` and `Download Zip` button
40+
const downloadPromise = await page
41+
.waitForEvent('download', { timeout: 2000 })
42+
.catch(() => {
43+
page.getByRole('button', { name: 'Code' }).click()
44+
page.getByRole('button', { name: 'Download Zip' }).click()
45+
return page.waitForEvent('download', { timeout: 2000 })
46+
})
47+
.catch(() => {
48+
// these catch calls are required to make sure if CI fails initially then we can have something to rely for further tests
49+
page.getByRole('button', { name: 'Code' }).click()
50+
page.getByRole('button', { name: 'Download Zip' }).click()
51+
return page.waitForEvent('download', { timeout: 2000 })
52+
})
53+
.catch(() => {
54+
page.getByRole('button', { name: 'Code' }).click()
55+
page.getByRole('button', { name: 'Download Zip' }).click()
56+
return page.waitForEvent('download', { timeout: 2000 })
57+
})
58+
59+
await downloadPromise.saveAs(
60+
`./dist-tests/text-classification-simple-${name}.zip`
61+
)
62+
})
63+
64+
test(`text-classification all ${name}`, async () => {
65+
await page.selectOption('select', 'template-text-classification')
66+
67+
await page.check('#include_test-checkbox')
68+
expect(await page.isChecked('#include_test-checkbox')).toBeTruthy()
69+
70+
await page.waitForSelector('text=README.md')
71+
await page.getByText('Training', { exact: true }).click()
72+
await page.check('#deterministic-checkbox')
73+
expect(await page.isChecked('#deterministic-checkbox')).toBeTruthy()
74+
75+
await page.click('text=Handlers')
76+
77+
await page.check('#save_training-checkbox')
78+
expect(await page.isChecked('#save_training-checkbox')).toBeTruthy()
79+
80+
await page.check('#save_evaluation-checkbox')
81+
expect(await page.isChecked('#save_evaluation-checkbox')).toBeTruthy()
82+
83+
await page.fill('#filename_prefix-input-text', 'training')
84+
expect(
85+
await page.$eval('#filename_prefix-input-text', (e) => e.value)
86+
).toBe('training')
87+
88+
await page.fill('#save_every_iters-input-number', '2')
89+
expect(
90+
await page.$eval('#save_every_iters-input-number', (e) => e.value)
91+
).toBe('2')
92+
93+
await page.fill('#n_saved-input-number', '2')
94+
expect(await page.$eval('#n_saved-input-number', (e) => e.value)).toBe('2')
95+
96+
await page.check('#terminate_on_nan-checkbox')
97+
expect(await page.isChecked('#terminate_on_nan-checkbox')).toBeTruthy()
98+
99+
await page.fill('#patience-input-number', '2')
100+
expect(await page.$eval('#patience-input-number', (e) => e.value)).toBe('2')
101+
102+
await page.fill('#limit_sec-input-number', '60')
103+
expect(await page.$eval('#limit_sec-input-number', (e) => e.value)).toBe(
104+
'60'
105+
)
106+
107+
await page.click('text=Loggers')
108+
await page.click('text=config.yaml')
109+
110+
const downloadPromise = await page
111+
.waitForEvent('download', { timeout: 2000 })
112+
.catch(() => {
113+
page.getByRole('button', { name: 'Code' }).click()
114+
page.getByRole('button', { name: 'Download Zip' }).click()
115+
return page.waitForEvent('download', { timeout: 2000 })
116+
})
117+
.catch(() => {
118+
page.getByRole('button', { name: 'Code' }).click()
119+
page.getByRole('button', { name: 'Download Zip' }).click()
120+
return page.waitForEvent('download', { timeout: 2000 })
121+
})
122+
.catch(() => {
123+
page.getByRole('button', { name: 'Code' }).click()
124+
page.getByRole('button', { name: 'Download Zip' }).click()
125+
return page.waitForEvent('download', { timeout: 2000 })
126+
})
127+
await downloadPromise.saveAs(
128+
`./dist-tests/text-classification-all-${name}.zip`
129+
)
130+
})
131+
132+
test(`text-classification launch ${name}`, async () => {
133+
await page.selectOption('select', 'template-text-classification')
134+
135+
await page.waitForSelector('text=README.md')
136+
await page.getByText('Training', { exact: true }).click()
137+
138+
await page.check('#use_dist-checkbox')
139+
expect(await page.isChecked('#use_dist-checkbox')).toBeTruthy()
140+
141+
expect(await page.isChecked('#dist-torchrun-radio')).toBeTruthy()
142+
143+
await page.click('text=Loggers')
144+
await page.click('text=config.yaml')
145+
146+
const downloadPromise = await page
147+
.waitForEvent('download', { timeout: 2000 })
148+
.catch(() => {
149+
page.getByRole('button', { name: 'Code' }).click()
150+
page.getByRole('button', { name: 'Download Zip' }).click()
151+
return page.waitForEvent('download', { timeout: 2000 })
152+
})
153+
.catch(() => {
154+
page.getByRole('button', { name: 'Code' }).click()
155+
page.getByRole('button', { name: 'Download Zip' }).click()
156+
return page.waitForEvent('download', { timeout: 2000 })
157+
})
158+
.catch(() => {
159+
page.getByRole('button', { name: 'Code' }).click()
160+
page.getByRole('button', { name: 'Download Zip' }).click()
161+
return page.waitForEvent('download', { timeout: 2000 })
162+
})
163+
164+
await downloadPromise.saveAs(
165+
`./dist-tests/text-classification-launch-${name}.zip`
166+
)
167+
})
168+
169+
test('text-classification spawn', async () => {
170+
await page.selectOption('select', 'template-text-classification')
171+
172+
await page.waitForSelector('text=README.md')
173+
await page.getByText('Training', { exact: true }).click()
174+
await page.check('#use_dist-checkbox')
175+
expect(await page.isChecked('#use_dist-checkbox')).toBeTruthy()
176+
177+
await page.check('#dist-spawn-radio')
178+
expect(await page.isChecked('#dist-spawn-radio')).toBeTruthy()
179+
180+
await page.click('text=Loggers')
181+
await page.click('text=config.yaml')
182+
183+
const downloadPromise = await page
184+
.waitForEvent('download', { timeout: 2000 })
185+
.catch(() => {
186+
page.getByRole('button', { name: 'Code' }).click()
187+
page.getByRole('button', { name: 'Download Zip' }).click()
188+
return page.waitForEvent('download', { timeout: 2000 })
189+
})
190+
.catch(() => {
191+
page.getByRole('button', { name: 'Code' }).click()
192+
page.getByRole('button', { name: 'Download Zip' }).click()
193+
return page.waitForEvent('download', { timeout: 2000 })
194+
})
195+
.catch(() => {
196+
page.getByRole('button', { name: 'Code' }).click()
197+
page.getByRole('button', { name: 'Download Zip' }).click()
198+
return page.waitForEvent('download', { timeout: 2000 })
199+
})
200+
await downloadPromise.saveAs(
201+
`./dist-tests/text-classification-spawn-${name}.zip`
202+
)
203+
})
204+
}

0 commit comments

Comments
 (0)