Skip to content

Commit 090af78

Browse files
authored
pre-commit: update config (microsoft#925)
* update config * apply precommit
1 parent ef91cab commit 090af78

17 files changed

+22
-30
lines changed

.pre-commit-config.yaml

+16-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
1+
default_language_version:
2+
python: python3
3+
4+
ci:
5+
autofix_prs: true
6+
autoupdate_commit_msg: '[pre-commit.ci] pre-commit suggestions'
7+
autoupdate_schedule: 'quarterly'
18

29
repos:
310
- repo: https://github.com/psf/black
4-
rev: 22.3.0
11+
rev: 23.1.0
512
hooks:
613
- id: black
7-
language_version: python3
8-
- repo: https://github.com/pycqa/flake8
9-
rev: 4.0.1
10-
hooks:
11-
- id: flake8
14+
- repo: https://github.com/pycqa/flake8
15+
rev: 6.0.0
16+
hooks:
17+
- id: flake8
1218
- repo: https://github.com/pre-commit/pre-commit-hooks
13-
rev: v4.3.0
19+
rev: v4.4.0
1420
hooks:
1521
- id: check-added-large-files
1622
- id: check-ast
23+
- id: check-yaml
24+
- id: check-toml
25+
- id: check-json
1726
- id: check-byte-order-marker
1827
- id: check-merge-conflict
1928
- id: detect-private-key

flaml/automl/automl.py

-2
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,6 @@ def _validate_data(
11041104
groups_val=None,
11051105
groups=None,
11061106
):
1107-
11081107
if X_train_all is not None and y_train_all is not None:
11091108
assert (
11101109
isinstance(X_train_all, np.ndarray)
@@ -1266,7 +1265,6 @@ def _validate_data(
12661265
self._state.groups = groups
12671266

12681267
def _prepare_data(self, eval_method, split_ratio, n_splits):
1269-
12701268
X_val, y_val = self._state.X_val, self._state.y_val
12711269
if issparse(X_val):
12721270
X_val = X_val.tocsr()

flaml/automl/ml.py

-1
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,6 @@ def get_val_loss(
439439
fit_kwargs={},
440440
free_mem_ratio=0,
441441
):
442-
443442
start = time.time()
444443
# if groups_val is not None:
445444
# fit_kwargs['groups_val'] = groups_val

flaml/automl/model.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ def _preprocess(self, X):
175175
return X
176176

177177
def _fit(self, X_train, y_train, **kwargs):
178-
179178
current_time = time.time()
180179
if "groups" in kwargs:
181180
kwargs = kwargs.copy()
@@ -447,7 +446,7 @@ def no_cuda(self):
447446
def _set_training_args(self, **kwargs):
448447
from .nlp.utils import date_str, Counter
449448

450-
for (key, val) in kwargs.items():
449+
for key, val in kwargs.items():
451450
assert key not in self.params, (
452451
"Since {} is in the search space, it cannot exist in 'custom_fit_kwargs' at the same time."
453452
"If you need to fix the value of {} to {}, the only way is to add a single-value domain in the search "

flaml/automl/nlp/huggingface/training_args.py

-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ def load_args_from_console():
112112

113113
@dataclass
114114
class Seq2SeqTrainingArgumentsForAuto(TrainingArgumentsForAuto):
115-
116115
model_path: str = field(
117116
default="t5-small",
118117
metadata={

flaml/automl/nlp/huggingface/utils.py

-2
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ def tokenize_and_align_labels(
135135

136136

137137
def tokenize_text_tokclassification(X, Y, tokenizer, hf_args=None):
138-
139138
# If the label_all_tokens flag is True, prepare two dicts label_to_id and b_to_i_label to convert the B- labels to I- labels
140139
label_to_id = {i: i for i in range(len(hf_args.label_list))}
141140
b_to_i_label = []
@@ -275,7 +274,6 @@ def tokenize_row(
275274

276275

277276
def tokenize_text_multiplechoice(X, tokenizer, hf_args=None):
278-
279277
t = X[["sent1", "sent2", "ending0", "ending1", "ending2", "ending3"]]
280278
_, tokenized_column_names = tokenize_swag(
281279
t.iloc[0],

flaml/automl/nlp/utils.py

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212

1313
def load_default_huggingface_metric_for_task(task):
14-
1514
if task == SEQCLASSIFICATION:
1615
return "accuracy"
1716
elif task == SEQREGRESSION:

flaml/tune/sample.py

-1
Original file line numberDiff line numberDiff line change
@@ -647,5 +647,4 @@ def qrandn(mean: float, sd: float, q: float):
647647
def polynomial_expansion_set(
648648
init_monomials: set, highest_poly_order: int = None, allow_self_inter: bool = False
649649
):
650-
651650
return PolynomialExpansionSet(init_monomials, highest_poly_order, allow_self_inter)

flaml/tune/searcher/variant_generator.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,9 @@ def _split_resolved_unresolved_values(
282282
_resolved_children,
283283
_unresolved_children,
284284
) = _split_resolved_unresolved_values(v)
285-
for (path, value) in _resolved_children.items():
285+
for path, value in _resolved_children.items():
286286
resolved_vars[(k,) + path] = value
287-
for (path, value) in _unresolved_children.items():
287+
for path, value in _unresolved_children.items():
288288
unresolved_vars[(k,) + path] = value
289289
elif isinstance(v, list):
290290
# Recurse into a list
@@ -293,9 +293,9 @@ def _split_resolved_unresolved_values(
293293
_resolved_children,
294294
_unresolved_children,
295295
) = _split_resolved_unresolved_values({i: elem})
296-
for (path, value) in _resolved_children.items():
296+
for path, value in _resolved_children.items():
297297
resolved_vars[(k,) + path] = value
298-
for (path, value) in _unresolved_children.items():
298+
for path, value in _unresolved_children.items():
299299
unresolved_vars[(k,) + path] = value
300300
else:
301301
resolved_vars[(k,)] = v

flaml/tune/tune.py

-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ def best_result(self) -> Dict:
142142

143143

144144
def report(_metric=None, **kwargs):
145-
146145
"""A function called by the HPO application to report final or intermediate
147146
results.
148147

test/automl/test_multiclass.py

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
class MyRegularizedGreedyForest(SKLearnEstimator):
1313
def __init__(self, task="binary", **config):
14-
1514
super().__init__(task, **config)
1615

1716
if task in CLASSIFICATION:

test/automl/test_python_log.py

-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@
1010

1111
class TestLogging(unittest.TestCase):
1212
def test_logging_level(self):
13-
1413
from flaml import logger, logger_formatter
1514

1615
with tempfile.TemporaryDirectory() as d:
17-
1816
training_log = os.path.join(d, "training.log")
1917

2018
# Configure logging for the FLAML logger

test/automl/test_training_log.py

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ class TestTrainingLog(unittest.TestCase):
1212
def test_training_log(
1313
self, path="test_training_log.log", estimator_list="auto", use_ray=False
1414
):
15-
1615
with TemporaryDirectory() as d:
1716
filename = os.path.join(d, path)
1817

test/nlp/utils.py

-1
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,6 @@ def get_toy_data_tokenclassification_tokenlabel():
15741574

15751575

15761576
def get_automl_settings(estimator_name="transformer"):
1577-
15781577
automl_settings = {
15791578
"gpu_per_trial": 0,
15801579
"max_iter": 3,

test/test_autovw.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def get_oml_to_vw(did, max_ns_num, ds_dir=VW_DS_DIR):
101101
target_attribute = ds.default_target_attribute
102102
# if target_attribute is None and did in OML_target_attribute_dict:
103103
# target_attribute = OML_target_attribute_dict[did]
104-
except (SSLError) as e:
104+
except SSLError as e:
105105
print(e)
106106
return
107107

test/tune/test_record_incumbent.py

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ def rosenbrock_function(config: dict):
1717

1818

1919
def test_record_incumbent(method="BlendSearch"):
20-
2120
if method != "CFOCat":
2221
search_space = {
2322
"x1": tune.randint(1, 9),

test/tune/test_reproducibility.py

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ def test_tune(externally_setup_searcher=False, use_ray=False, use_raytune=False)
3535
"height": tune.uniform(-100, 100),
3636
}
3737
if externally_setup_searcher is True:
38-
3938
searcher = BlendSearch(
4039
space=search_space,
4140
time_budget_s=5,

0 commit comments

Comments
 (0)