Add Optional to remaining types (#37808)
More Optional typing Signed-off-by: cyy <cyyever@outlook.com>
This commit is contained in:
@@ -19,6 +19,7 @@ import os
|
||||
import unittest
|
||||
from copy import deepcopy
|
||||
from functools import partial
|
||||
from typing import Optional
|
||||
|
||||
import datasets
|
||||
from parameterized import parameterized
|
||||
@@ -1252,8 +1253,8 @@ class TestDeepSpeedWithLauncher(TestCasePlus):
|
||||
do_eval: bool = True,
|
||||
quality_checks: bool = True,
|
||||
fp32: bool = False,
|
||||
extra_args_str: str = None,
|
||||
remove_args_str: str = None,
|
||||
extra_args_str: Optional[str] = None,
|
||||
remove_args_str: Optional[str] = None,
|
||||
):
|
||||
# we are doing quality testing so using a small real model
|
||||
output_dir = self.run_trainer(
|
||||
@@ -1285,8 +1286,8 @@ class TestDeepSpeedWithLauncher(TestCasePlus):
|
||||
do_eval: bool = True,
|
||||
distributed: bool = True,
|
||||
fp32: bool = False,
|
||||
extra_args_str: str = None,
|
||||
remove_args_str: str = None,
|
||||
extra_args_str: Optional[str] = None,
|
||||
remove_args_str: Optional[str] = None,
|
||||
):
|
||||
max_len = 32
|
||||
data_dir = self.test_file_dir / "../fixtures/tests_samples/wmt_en_ro"
|
||||
|
||||
@@ -17,6 +17,7 @@ import os
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
from unittest.mock import patch
|
||||
|
||||
from parameterized import parameterized
|
||||
@@ -270,13 +271,13 @@ class TestTrainerExt(TestCasePlus):
|
||||
learning_rate: float = 3e-3,
|
||||
optim: str = "adafactor",
|
||||
distributed: bool = False,
|
||||
extra_args_str: str = None,
|
||||
extra_args_str: Optional[str] = None,
|
||||
eval_steps: int = 0,
|
||||
predict_with_generate: bool = True,
|
||||
do_train: bool = True,
|
||||
do_eval: bool = True,
|
||||
do_predict: bool = True,
|
||||
n_gpus_to_use: int = None,
|
||||
n_gpus_to_use: Optional[int] = None,
|
||||
):
|
||||
data_dir = self.test_file_dir / "../fixtures/tests_samples/wmt_en_ro"
|
||||
output_dir = self.get_auto_remove_tmp_dir()
|
||||
|
||||
@@ -41,7 +41,7 @@ class BridgeTowerImageProcessingTester:
|
||||
self,
|
||||
parent,
|
||||
do_resize: bool = True,
|
||||
size: dict[str, int] = None,
|
||||
size: Optional[dict[str, int]] = None,
|
||||
size_divisor: int = 32,
|
||||
do_rescale: bool = True,
|
||||
rescale_factor: Union[int, float] = 1 / 255,
|
||||
|
||||
@@ -92,12 +92,12 @@ class PatchTSMixerModelTester:
|
||||
head_dropout: float = 0.2,
|
||||
# forecast related
|
||||
prediction_length: int = 16,
|
||||
out_channels: int = None,
|
||||
out_channels: Optional[int] = None,
|
||||
# Classification/regression related
|
||||
# num_labels: int = 3,
|
||||
num_targets: int = 3,
|
||||
output_range: list = None,
|
||||
head_aggregation: str = None,
|
||||
output_range: Optional[list] = None,
|
||||
head_aggregation: Optional[str] = None,
|
||||
# Trainer related
|
||||
batch_size=13,
|
||||
is_training=True,
|
||||
|
||||
@@ -41,12 +41,12 @@ class TvpImageProcessingTester:
|
||||
do_resize: bool = True,
|
||||
size: dict[str, int] = {"longest_edge": 40},
|
||||
do_center_crop: bool = False,
|
||||
crop_size: dict[str, int] = None,
|
||||
crop_size: Optional[dict[str, int]] = None,
|
||||
do_rescale: bool = False,
|
||||
rescale_factor: Union[int, float] = 1 / 255,
|
||||
do_pad: bool = True,
|
||||
pad_size: dict[str, int] = {"height": 80, "width": 80},
|
||||
fill: int = None,
|
||||
fill: Optional[int] = None,
|
||||
pad_mode: PaddingMode = None,
|
||||
do_normalize: bool = True,
|
||||
image_mean: Optional[Union[float, list[float]]] = [0.48145466, 0.4578275, 0.40821073],
|
||||
|
||||
@@ -28,7 +28,7 @@ from collections import OrderedDict
|
||||
from functools import lru_cache
|
||||
from itertools import takewhile
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, Any, Union
|
||||
from typing import TYPE_CHECKING, Any, Optional, Union
|
||||
|
||||
from parameterized import parameterized
|
||||
|
||||
@@ -173,7 +173,7 @@ def _test_subword_regularization_tokenizer(in_queue, out_queue, timeout):
|
||||
|
||||
def check_subword_sampling(
|
||||
tokenizer: PreTrainedTokenizer,
|
||||
text: str = None,
|
||||
text: Optional[str] = None,
|
||||
test_sentencepiece_ignore_case: bool = True,
|
||||
) -> None:
|
||||
"""
|
||||
@@ -321,9 +321,9 @@ class TokenizerTesterMixin:
|
||||
self,
|
||||
expected_encoding: dict,
|
||||
model_name: str,
|
||||
revision: str = None,
|
||||
sequences: list[str] = None,
|
||||
decode_kwargs: dict[str, Any] = None,
|
||||
revision: Optional[str] = None,
|
||||
sequences: Optional[list[str]] = None,
|
||||
decode_kwargs: Optional[dict[str, Any]] = None,
|
||||
padding: bool = True,
|
||||
):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user