Repository navigation
Commit 89e108c
authored
Fix the Samsung MobileBert test setup so it can run (pytorch#22550)
### Summary
The Samsung model test job runs every test under
`backends/samsung/test/models`. One of those tests, the MobileBert
fine-tuning test, always errors out before it does any work:
```
ERROR: setUpClass (test_mobilebert_finetuning.Test_Milestone_MobileBertFinetune)
AttributeError: type object 'Test_Milestone_MobileBertFinetune' has no attribute 'model_cache_dir'
```
One error fails the whole job, so the other ten Samsung model tests
passing does not help. The job only runs the tests when a Samsung device
is available, which is why this looks like it comes and goes.
There were three separate problems stacked in the test setup, and each
one was hidden behind the one before it:
1. `setUpClass` read `cls.model_cache_dir`, which is not defined
anywhere.
2. It passed that value to `patch_mobilebert_finetuning()`, which takes
no arguments. Python only checks the number of arguments when the call
happens, so this could not be seen until the first problem was gone.
3. The setup replaced `load_tokenizer` with a copy of itself that left
out the model name, so `AutoTokenizer.from_pretrained()` had nothing to
load.
The replacement tokenizer loader was the same as the real one except for
the missing model name, so it could only ever do less than the real one.
Removing the setup that installed it fixes all three problems at once
and lets the test use the real loader. The test now has the same shape
as the other ten tests in the same directory, which build a model and
check it with no extra setup.
### Test plan
Ran the real test collection and setup for this file before and after
the change, with the heavy third party dependencies stubbed out so only
the setup path was under test.
- Before: reproduces the same `AttributeError` seen in CI, and never
reaches the test body.
- After: setup succeeds and the test body is reached.
Also checked that `model_cache_dir`, `setUpClass` and the now unused
`AutoTokenizer` import are all gone, and that the file still compiles.1 parent c65b23a commit 89e108c
1 file changed
Lines changed: 0 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | 15 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | 16 | | |
35 | 17 | | |
36 | 18 | | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | 19 | | |
46 | 20 | | |
47 | 21 | | |
| |||
0 commit comments