-
Notifications
You must be signed in to change notification settings - Fork 34
/
test_tracking_utils.py
211 lines (200 loc) · 6.08 KB
/
test_tracking_utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
import pytest
from fixtures import get_full_taskgraph
from tracking.translations_parser.utils import (
ParsedTaskLabel,
build_task_name,
parse_task_label,
parse_gcp_metric,
)
@pytest.mark.parametrize(
"task_label, parsed_values",
[
(
"evaluate-teacher-flores-flores_aug-title_devtest-lt-en-1_2",
("teacher-1", "flores", "devtest", "aug-title"),
),
(
"evaluate-quantized-mtdata_aug-mix_Neulab-tedtalks_eng-lit-lt-en",
("quantized", "mtdata", "Neulab-tedtalks_eng-lit", "aug-mix"),
),
(
"evaluate-finetune-teacher-sacrebleu-wmt19-lt-en-2_2",
("finetune-teacher-2", "sacrebleu", "wmt19", None),
),
(
"evaluate-student-sacrebleu-wmt19-lt-en",
("student", "sacrebleu", "wmt19", None),
),
(
"train-student-en-hu",
("student", None, None, None),
),
(
"eval_teacher-ensemble_mtdata_Neulab-tedtalks_test-1-eng-nld",
("teacher-ensemble", "mtdata", "Neulab-tedtalks_test-1-eng-nld", None),
),
(
"eval_student-finetuned_flores_devtest",
("student-finetune", "flores", "devtest", None),
),
(
"eval_teacher-base0_flores_devtest",
("teacher-base-0", "flores", "devtest", None),
),
(
"train-backwards-en-ca",
("backwards", None, None, None),
),
(
"evaluate-teacher-flores-flores_dev-en-ca-1/2",
("teacher-1", "flores", "dev", None),
),
(
"train-teacher-ensemble",
("teacher-ensemble", None, None, None),
),
(
"evaluate-teacher-flores-flores_dev-en-ca",
("teacher-1", "flores", "dev", None),
),
(
"train-finetune-student-ru-en",
("finetune-student", None, None, None),
),
(
"train-teacher-ru-en-1",
("teacher-1", None, None, None),
),
(
"evaluate-backward-url-gcp_pytest-dataset_a0017e-en-ru",
("backwards", "url", "gcp_pytest-dataset_a0017e", None),
),
(
"train-teacher-ast-en-1",
("teacher-1", None, None, None),
),
(
# Test the 3-letter language codes like "Asturian".
"evaluate-student-sacrebleu-wmt19-ast-en",
("student", "sacrebleu", "wmt19", None),
),
(
"evaluate-teacher-flores-devtest-ru-en-1",
("teacher-1", "flores", "devtest", None),
),
],
)
def test_parse_task_label(task_label, parsed_values):
assert parse_task_label(task_label) == ParsedTaskLabel(*parsed_values)
def test_parse_labels_on_full_taskgraph():
"""Ensure that all the taskgraph task labels parse."""
for task in get_full_taskgraph():
if not (
task.startswith("train-")
or task.startswith("evaluate-")
or task.startswith("finetune-")
):
continue
if task.startswith("train-vocab"):
continue
if "https://storage.googleapis.com" in task:
# This is a temporary mitigation to get this landed until #611 is landed.
continue
print(task)
# This throws when it fails to parse.
parse_task_label(task)
@pytest.mark.parametrize(
"task_tags, values",
[
(
{
"os": "linux",
"kind": "train-student",
"label": "train-student-lt-en",
},
("train", "student"),
),
(
{
"os": "linux",
"kind": "evaluate",
"label": "evaluate-teacher-sacrebleu-sacrebleu_aug-upper_wmt19-lt-en-2/2",
},
("evaluate", "teacher-2"),
),
],
)
def test_build_task_name(task_tags, values):
task = {"tags": task_tags}
assert build_task_name(task) == values
@pytest.mark.parametrize(
"filename, parsed_values",
[
(
"flores_aug-mix_devtest",
("flores", "aug-mix", "devtest"),
),
(
"flores_aug-title_devtest",
("flores", "aug-title", "devtest"),
),
(
"flores_aug-title-strict_devtest",
("flores", "aug-title-strict", "devtest"),
),
(
"flores_aug-typos_devtest",
("flores", "aug-typos", "devtest"),
),
(
"flores_aug-upper_devtest",
("flores", "aug-upper", "devtest"),
),
(
"flores_aug-upper-strict_devtest",
("flores", "aug-upper-strict", "devtest"),
),
(
"flores_devtest",
("flores", None, "devtest"),
),
(
"mtdata_aug-mix_Neulab-tedtalks_test-1-eng-lit",
("mtdata", "aug-mix", "Neulab-tedtalks_test-1-eng-lit"),
),
(
"mtdata_Neulab-tedtalks_test-1-eng-lit",
("mtdata", None, "Neulab-tedtalks_test-1-eng-lit"),
),
(
"sacrebleu_aug-mix_wmt19",
("sacrebleu", "aug-mix", "wmt19"),
),
(
"sacrebleu_aug-title-strict_wmt19",
("sacrebleu", "aug-title-strict", "wmt19"),
),
(
"sacrebleu_aug-title_wmt19",
("sacrebleu", "aug-title", "wmt19"),
),
(
"sacrebleu_aug-typos_wmt19",
("sacrebleu", "aug-typos", "wmt19"),
),
(
"sacrebleu_aug-upper-strict_wmt19",
("sacrebleu", "aug-upper-strict", "wmt19"),
),
(
"sacrebleu_wmt19",
("sacrebleu", None, "wmt19"),
),
],
)
def test_gcp_metric(filename, parsed_values):
assert tuple(parse_gcp_metric(filename)) == parsed_values
@pytest.mark.parametrize("filename", ["devtest", "tc_Tatoeba-Challenge-v2021-08-07", "test"])
def test_wrong_gcp_metric(filename):
with pytest.raises(ValueError):
parse_gcp_metric(filename)