Skip to content

Commit 5d9c69c

Browse files
authored
Add flake8-print in pre-commit (#939)
* Add flake8-print in pre-commit config * Replace print statements with logging
1 parent 666ca68 commit 5d9c69c

File tree

6 files changed

+13
-6
lines changed

6 files changed

+13
-6
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[flake8]
22
max-line-length = 100
33
show-source = True
4-
select = C,E,F,W,B
4+
select = C,E,F,W,B,T
55
ignore = E203, E402, W503
66
per-file-ignores =
77
*__init__.py:F401

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ repos:
1919
- id: flake8
2020
name: flake8 openml
2121
files: openml/*
22+
additional_dependencies:
23+
- flake8-print==3.1.4
2224
- id: flake8
2325
name: flake8 tests
2426
files: tests/*
27+
additional_dependencies:
28+
- flake8-print==3.1.4

openml/extensions/sklearn/extension.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,7 @@ def _prevent_optimize_n_jobs(self, model):
13161316
"Could not find attribute "
13171317
"param_distributions."
13181318
)
1319-
print(
1319+
logger.warning(
13201320
"Warning! Using subclass BaseSearchCV other than "
13211321
"{GridSearchCV, RandomizedSearchCV}. "
13221322
"Should implement param check. "

tests/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
# exploiting the fact that conftest.py always resides in the root directory for tests
4141
static_dir = os.path.dirname(os.path.abspath(__file__))
4242
logger.info("static directory: {}".format(static_dir))
43-
print("static directory: {}".format(static_dir))
4443
while True:
4544
if "openml" in os.listdir(static_dir):
4645
break

tests/test_datasets/test_dataset_functions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,9 @@ def test_publish_fetch_ignore_attribute(self):
11601160
except Exception as e:
11611161
# returned code 273: Dataset not processed yet
11621162
# returned code 362: No qualities found
1163-
print("Failed to fetch dataset:{} with '{}'.".format(dataset.id, str(e)))
1163+
TestBase.logger.error(
1164+
"Failed to fetch dataset:{} with '{}'.".format(dataset.id, str(e))
1165+
)
11641166
time.sleep(10)
11651167
continue
11661168
if downloaded_dataset is None:

tests/test_study/test_study_examples.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ def test_Figure1a(self):
4848
clf, task, avoid_duplicate_runs=False
4949
) # run classifier on splits (requires API key)
5050
score = run.get_metric_fn(sklearn.metrics.accuracy_score) # print accuracy score
51-
print("Data set: %s; Accuracy: %0.2f" % (task.get_dataset().name, score.mean()))
51+
TestBase.logger.info(
52+
"Data set: %s; Accuracy: %0.2f" % (task.get_dataset().name, score.mean())
53+
)
5254
run.publish() # publish the experiment on OpenML (optional)
5355
TestBase._mark_entity_for_removal("run", run.run_id)
5456
TestBase.logger.info(
5557
"collected from {}: {}".format(__file__.split("/")[-1], run.run_id)
5658
)
57-
print("URL for run: %s/run/%d" % (openml.config.server, run.run_id))
59+
TestBase.logger.info("URL for run: %s/run/%d" % (openml.config.server, run.run_id))

0 commit comments

Comments
 (0)