Skip to content

Commit ae23fdb

Browse files
matthew-e-hopkinschanglan
authored andcommitted
[Pre py3.12 Upgrade] Update black pylint
GitOrigin-RevId: fa61c32
1 parent 0563015 commit ae23fdb

108 files changed

Lines changed: 368 additions & 141 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.pylintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ disable=abstract-method,
111111
no-member, # Config objects use dynamic members generated by attrs.
112112
no-name-in-module,
113113
no-self-use,
114+
not-callable,
114115
nonzero-method,
115116
oct-method,
116117
old-division,
@@ -163,6 +164,8 @@ disable=abstract-method,
163164
xrange-builtin,
164165
zip-builtin-not-iterating,
165166

167+
# Increase default from 5 to 9
168+
max-positional-arguments=9
166169

167170
[REPORTS]
168171

axlearn/audio/decoder_asr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ def tokens_to_scores(
10131013

10141014
return tokens_to_scores
10151015

1016-
def beam_search_decode(
1016+
def beam_search_decode( # pytype: disable=signature-mismatch
10171017
self,
10181018
input_batch: Nested[Tensor],
10191019
num_decodes: int,
@@ -1225,7 +1225,7 @@ def _validate_decode_batch(self, input_batch: Nested[Tensor]):
12251225
if "prefix" not in input_batch:
12261226
raise ValueError("Input batch is expected to contain `prefix`.")
12271227

1228-
def beam_search_decode(
1228+
def beam_search_decode( # pytype: disable=signature-mismatch
12291229
self,
12301230
input_batch: Nested[Tensor],
12311231
num_decodes: int,

axlearn/audio/evaler_asr_test.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,13 +302,19 @@ def test_brevity_penalty(self):
302302

303303
# Without brevity penalty, outputs match exactly.
304304
outputs = _compute_metrics(hypotheses, references, vocab_file=_1K_VOCAB_FILE)
305-
self.assertNestedAllClose(outputs["word_errors/wer"].mean, 0.0)
306-
self.assertNestedAllClose(outputs["word_errors/sentence_accuracy"].mean, 1.0)
305+
self.assertNestedAllClose(
306+
outputs["word_errors/wer"].mean, 0.0 # pytype: disable=attribute-error
307+
)
308+
self.assertNestedAllClose(
309+
outputs["word_errors/sentence_accuracy"].mean, 1.0 # pytype: disable=attribute-error
310+
)
307311

308312
# With brevity penalty, DummyModel should emit fewer tokens.
309313
brevity_penalty = brevity_penalty_fn(alpha=0.9, bp_type="t5")
310314
outputs = _compute_metrics(
311315
hypotheses, references, brevity_penalty=brevity_penalty, vocab_file=_1K_VOCAB_FILE
312316
)
313-
self.assertGreater(outputs["word_errors/wer"].mean, 0.0)
314-
self.assertNestedAllClose(outputs["word_errors/sentence_accuracy"].mean, 0.0)
317+
self.assertGreater(outputs["word_errors/wer"].mean, 0.0) # pytype: disable=attribute-error
318+
self.assertNestedAllClose(
319+
outputs["word_errors/sentence_accuracy"].mean, 0.0 # pytype: disable=attribute-error
320+
)

axlearn/audio/model_asr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def predict(self, input_batch: Nested[Tensor]) -> Nested[Tensor]:
5959
)
6060
return dict(logits=logits)
6161

62-
def forward(
62+
def forward( # pytype: disable=signature-mismatch
6363
self, input_batch: Nested[Tensor], *, return_aux: bool = False
6464
) -> tuple[Tensor, Nested[Tensor]]:
6565
"""Computes loss and predictions (such as logits) in auxiliary outputs.
@@ -95,7 +95,7 @@ def forward(
9595
)
9696
return loss, aux_outputs if return_aux else {}
9797

98-
def beam_search_decode(
98+
def beam_search_decode( # pytype: disable=signature-mismatch
9999
self, input_batch: Nested[Tensor], num_decodes: int, **kwargs
100100
) -> DecodeOutputs:
101101
"""Performs beam search decoding.

axlearn/cloud/common/scheduler_test.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,9 @@ def test_validate_tiers(self):
210210
sched.schedule(resource_limits=[], **common_kwargs)
211211

212212
with self.assertRaisesRegex(ValueError, "sequence"):
213-
sched.schedule(resource_limits={"v4": 10, "v3": 3}, **common_kwargs)
213+
sched.schedule(
214+
resource_limits={"v4": 10, "v3": 3}, **common_kwargs
215+
) # pytype: disable=wrong-arg-types
214216

215217
sched.schedule(resource_limits=[{"v4": 10, "v3": 3}], **common_kwargs)
216218

@@ -582,7 +584,7 @@ def test_schedule(
582584
{"unused_limits": [{"v4": 4}, {"v4": 8}]},
583585
)
584586
def test_schedule_result(self, unused_limits: Optional[Sequence[ResourceMap[int]]]):
585-
schedule_result = BaseScheduler.ScheduleResults(
587+
schedule_result = BaseScheduler.ScheduleResults( # pytype: disable=wrong-arg-types
586588
project_limits={"a": {"v4": 5}, "b": {"unknown": 0, "v4": 1}},
587589
project_usages={"a": {"v4": 5}, "b": {"unknown": 0, "v4": 1}},
588590
job_verdicts={"a1": True, "a2": False, "b1": False, "b2": True},

axlearn/cloud/gcp/bundler_test.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def test_wait_until_finished_is_no_op_if_async_false(self):
142142
# Should be a no-op if is_async=False.
143143
cfg = self._get_test_cloud_build_bundler()
144144

145-
with self._mock_status(None) as mock_status:
145+
with self._mock_status(None) as mock_status: # pytype: disable=wrong-arg-types
146146
b = cfg.set(is_async=False).instantiate()
147147
b.wait_until_finished("test-name")
148148
self.assertFalse(mock_status.called)
@@ -151,7 +151,7 @@ def test_wait_until_finished_is_called_with_happy_status_path(self):
151151
# Tests happy path: transitions from no status -> pending -> success.
152152
cfg = self._get_test_cloud_build_bundler()
153153

154-
with self._mock_status(
154+
with self._mock_status( # pytype: disable=wrong-arg-types
155155
None, CloudBuildStatus.PENDING, CloudBuildStatus.SUCCESS
156156
) as mock_status:
157157
b = cfg.set(is_async=True).instantiate()
@@ -162,7 +162,7 @@ def test_wait_until_finished_raises_runtime_error_with_cloud_build_status_failur
162162
# Tests that we raise a runtime error if CloudBuildStatus.FAILURE status is returned.
163163
cfg = self._get_test_cloud_build_bundler()
164164

165-
with self._mock_status(
165+
with self._mock_status( # pytype: disable=wrong-arg-types
166166
None, CloudBuildStatus.PENDING, CloudBuildStatus.FAILURE
167167
) as mock_status:
168168
b = cfg.set(is_async=True).instantiate()
@@ -177,7 +177,9 @@ def test_wait_until_finished_retries_with_runtime_error(self):
177177
# Tests that the query is retried if retrieving status fails with a RuntimeError.
178178
cfg = self._get_test_cloud_build_bundler()
179179

180-
with self._mock_status(RuntimeError("fake error"), CloudBuildStatus.SUCCESS) as mock_status:
180+
with self._mock_status(
181+
RuntimeError("fake error"), CloudBuildStatus.SUCCESS
182+
) as mock_status: # pytype: disable=wrong-arg-types
181183
b = cfg.set(is_async=True).instantiate()
182184
b.wait_until_finished("test-name")
183185
self.assertEqual(2, mock_status.call_count)
@@ -189,7 +191,7 @@ def test_wait_until_finished_triggers_timeout(self):
189191
with mock.patch("time.perf_counter") as mock_perf_counter:
190192
mock_perf_counter.side_effect = [0, 10, 500, 3601]
191193

192-
with self._mock_status(
194+
with self._mock_status( # pytype: disable=wrong-arg-types
193195
None, CloudBuildStatus.PENDING, CloudBuildStatus.PENDING
194196
) as mock_status:
195197
b = cfg.set(is_async=True).instantiate()

axlearn/cloud/gcp/jobs/launch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ def _wrapped_usage(
781781
if __name__ == "__main__":
782782
# remove FLAGS injected by tensorflow and array record package during import
783783
# example: import grain.python as grain
784-
# TODO: remove this after we stop using the global FLAG for axlearn flags
784+
# TODO: remove this after we stop using the global FLAG for ajax/axlearn flags
785785
flags_to_remove = []
786786
modules_to_exclude = ["tensorflow", "grain", "array_record", "orbax"]
787787
for module_name, flags_list in FLAGS.flags_by_module_dict().items():

axlearn/cloud/gcp/jobs/launch_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ def test_list(self):
393393
class TestBastionManagedGKEJob(TestWithTemporaryCWD):
394394
"""Tests BastionManagedGKEJob."""
395395

396-
def run(self, **kwargs):
396+
def run(self, **kwargs): # pytype: disable=signature-mismatch
397397
# Run tests under mock settings.
398398
self._settings = default_mock_settings()
399399
patch_name = mock.patch(f"{launch.__name__}.generate_job_name", return_value="job-name")
@@ -439,6 +439,8 @@ def run(self, **kwargs):
439439
],
440440
action=_ACTIONS,
441441
)
442+
# TODO: Try to reduce positional arguments
443+
# pylint: disable-next=too-many-positional-arguments
442444
def test_tpu_flags(
443445
self,
444446
action,

axlearn/cloud/gcp/jobset_utils_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ def test_validate_jobset_name(self):
190190
additional_node_networks=[None, "network-1:subnet-1,network-2:subnet-2"],
191191
image_id=[None, "my-image-id"],
192192
)
193+
# TODO: Try to reduce positional arguments
194+
# pylint: disable-next=too-many-positional-arguments
193195
def test_build_pod(
194196
self,
195197
bundler_cls: type[Bundler],

axlearn/cloud/gcp/lws_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class TPULeaderWorkerTemplate(TPUJobBuilder):
9696

9797
def __call__(self) -> Sequence[Nested[Any]]:
9898
system = USER_FACING_NAME_TO_SYSTEM_CHARACTERISTICS[self._tpu_type]
99-
return dict(
99+
return dict( # pytype: disable=bad-return-type
100100
size=system.vms_per_slice,
101101
workerTemplate=self._build_pod(),
102102
)

0 commit comments

Comments
 (0)