Skip to content

Commit 2895a0b

Browse files
authored
Merge pull request #15885 from kubernetes/revert-15761-python3
Revert "Move hack job to python3 and enable PY3 linting"
2 parents e3790bd + ed64df7 commit 2895a0b

23 files changed

+66
-56
lines changed

WORKSPACE

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,11 @@ load("@npm_bazel_typescript//:index.bzl", "ts_setup_workspace")
6868

6969
ts_setup_workspace()
7070

71-
load("@rules_python//python:pip.bzl", "pip_import")
71+
load("@io_bazel_rules_python//python:pip.bzl", "pip_import")
7272

7373
pip_import(
7474
name = "py_deps",
75-
python_interpreter = "python2",
76-
requirements = "//:requirements2.txt",
77-
)
78-
79-
load("@py_deps//:requirements.bzl", "pip_install")
80-
81-
pip_install()
82-
83-
pip_import(
84-
name = "py3_deps",
85-
python_interpreter = "python3",
86-
requirements = "//:requirements3.txt",
75+
requirements = "//:requirements.txt",
8776
)
8877

8978
load("//:py.bzl", "python_repos")

experiment/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@py3_deps//:requirements.bzl", "requirement")
1+
load("@py_deps//:requirements.bzl", "requirement")
22

33
py_binary(
44
name = "flakedetector",

experiment/find_developers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def load_content(data):
4343

4444

4545
@functools.total_ordering
46-
class User: # pylint: disable=too-few-public-methods
46+
class User(object): # pylint: disable=too-few-public-methods
4747
"""Store .user and number of .total and .recent commits."""
4848
def __init__(self, blob):
4949
self.user = blob['author']['login']

experiment/graphql_issue_example.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
# USAGE: find_issues.py <github_token>
1818

19+
# Required for pylint: 1.9.4 to tokenize the python3 print function.
20+
from __future__ import print_function
21+
1922
import sys
2023
import json
2124
import argparse

experiment/parse_build_log.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
_CURRENT_YEAR = datetime.datetime.utcnow().year
3030

3131

32-
class TestOutput:
32+
class TestOutput(object):
3333
def __init__(self):
3434
self._lines = []
3535
self._start = None
@@ -81,7 +81,8 @@ def _get_tests(log):
8181
current_test = TestOutput()
8282
if len(ended_test) <= 1:
8383
continue
84-
yield ended_test
84+
else:
85+
yield ended_test
8586
else:
8687
current_test.append(match.group(1))
8788
yield current_test

hack/BUILD.bazel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@py3_deps//:requirements.bzl", "requirement")
1+
load("@py_deps//:requirements.bzl", "requirement")
22
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary", "nodejs_test")
33

44
package(default_visibility = ["//visibility:public"])
@@ -226,13 +226,14 @@ test_suite(
226226
py_binary(
227227
name = "pylint_bin",
228228
srcs = ["pylint_bin.py"],
229-
python_version = "PY3",
229+
python_version = "PY2",
230230
tags = ["lint"],
231231
# NOTE: this should only contain direct third party imports and pylint
232232
deps = [
233233
requirement("astroid"),
234234
requirement("backports.functools_lru_cache"),
235235
requirement("configparser"),
236+
requirement("enum34"),
236237
requirement("influxdb"),
237238
requirement("isort"),
238239
requirement("lazy-object-proxy"),

hack/pylint_bin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python3
1+
#!/usr/bin/env python2
22

33
# Copyright 2017 The Kubernetes Authors.
44
#

hack/verify-pylint.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@ export PYLINTHOME=$TEST_TMPDIR
3636

3737
shopt -s extglob globstar
3838

39-
# TODO(clarketm): remove `boskos` exclusion after upgrading to PY3.
40-
"$DIR/pylint_bin" !(gubernator|external|vendor|jenkins|scenarios|triage|boskos|bazel-*)/**/*.py
39+
# TODO(clarketm) there is no version of `pylint` that supports "both" PY2 and PY3
40+
# I am disabling pylint checks for python3 files until migration complete
41+
"$DIR/pylint_bin" !(kettle|metrics|triage|velodrome|hack|gubernator|external|vendor|testgrid|bazel-*)/**/*.py

kettle/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@py3_deps//:requirements.bzl", "requirement")
1+
load("@py_deps//:requirements.bzl", "requirement")
22

33
py_test(
44
name = "make_db_test",

kettle/make_json.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,14 @@ def make_result(name, time, failure_text):
8181

8282

8383
def buckets_yaml():
84-
import ruamel.yaml as yaml # pylint: disable=import-outside-toplevel
84+
import ruamel.yaml as yaml # does not support pypy
8585
with open(os.path.dirname(os.path.abspath(__file__))+'/buckets.yaml') as fp:
8686
return yaml.safe_load(fp)
8787

8888
# pypy compatibility hack
8989
def python_buckets_yaml(python='python3'):
9090
return json.loads(subprocess.check_output(
91-
[python, '-c',
92-
'import json, ruamel.yaml as yaml; print(json.dumps(yaml.safe_load(open("buckets.yaml"))))'
93-
],
91+
[python, '-c', 'import json, ruamel.yaml as yaml; print(json.dumps(yaml.safe_load(open("buckets.yaml"))))'],
9492
cwd=os.path.dirname(os.path.abspath(__file__))).decode("utf-8"))
9593

9694
for attempt in [python_buckets_yaml, buckets_yaml, lambda: python_buckets_yaml(python='python')]:

kettle/make_json_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def expect(args, needles, negneedles, expected_ret=None):
135135
for needle in negneedles:
136136
# Only match negative needles in the middle of a word, to avoid
137137
# failures on timestamps that happen to contain a short number.
138-
self.assertNotRegexpMatches(result, r'\b%s\b' % needle) # pylint: disable=deprecated-method
138+
self.assertNotRegexpMatches(result, r'\b%s\b' % needle)
139139

140140
add_build('some-job/123', last_month, last_month + 10, 'SUCCESS', junits)
141141
add_build('some-job/456', now - 10, now, 'FAILURE', junits)

kettle/stream.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,15 @@ def get_started_finished(gcs_client, db, todo):
6969
pool = multiprocessing.pool.ThreadPool(16)
7070
try:
7171
for ack_id, (build_dir, started, finished) in pool.imap_unordered(
72-
lambda ack_id_job_build: (ack_id_job_build[0], gcs_client.get_started_finished(
73-
ack_id_job_build[1], ack_id_job_build[2])),
72+
lambda ack_id_job_build: (ack_id_job_build[0], gcs_client.get_started_finished(ack_id_job_build[1], ack_id_job_build[2])),
7473
todo):
7574
if finished:
7675
if not db.insert_build(build_dir, started, finished):
7776
print('already present??')
7877
start = time.localtime(started.get('timestamp', 0) if started else 0)
7978
print((build_dir, bool(started), bool(finished),
80-
time.strftime('%F %T %Z', start),
81-
finished and finished.get('result')))
79+
time.strftime('%F %T %Z', start),
80+
finished and finished.get('result')))
8281
build_dirs.append(build_dir)
8382
acks.append(ack_id)
8483
else:

load.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ def repositories():
4848
# Python setup
4949
# pip_import() calls must live in WORKSPACE, otherwise we get a load() after non-load() error
5050
git_repository(
51-
name = "rules_python",
52-
commit = "94677401bc56ed5d756f50b441a6a5c7f735a6d4",
51+
name = "io_bazel_rules_python",
52+
commit = "9d68f24659e8ce8b736590ba1e4418af06ec2552",
5353
remote = "https://github.com/bazelbuild/rules_python.git",
54-
shallow_since = "1573842889 -0500",
54+
shallow_since = "1565801665 -0400",
5555
)
5656

5757
# TODO(fejta): get this to work

metrics/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@py3_deps//:requirements.bzl", "requirement")
1+
load("@py_deps//:requirements.bzl", "requirement")
22

33
package(default_visibility = ["//visibility:public"])
44

metrics/bigquery.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def do_jq(jq_filter, data_filename, out_filename, jq_bin='jq'):
6565
check([jq_bin, jq_filter, data_filename], stdout=out_file)
6666

6767

68-
class BigQuerier:
68+
class BigQuerier(object):
6969
def __init__(self, project, bucket_path, backfill_days, influx_client):
7070
if not project:
7171
raise ValueError('project', project)

py.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
1616
load("@io_bazel_rules_appengine//appengine:py_appengine.bzl", "py_appengine_repositories")
1717
load(
18-
"@py3_deps//:requirements.bzl",
18+
"@py_deps//:requirements.bzl",
1919
"pip_install",
2020
)
2121

releng/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@py3_deps//:requirements.bzl", "requirement")
1+
load("@py_deps//:requirements.bzl", "requirement")
22

33
py_binary(
44
name = "generate_tests",

releng/generate_tests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def apply_job_overrides(envs_or_args, job_envs_or_args):
107107
envs_or_args.append(job_env_or_arg)
108108

109109

110-
class E2ENodeTest:
110+
class E2ENodeTest(object):
111111

112112
def __init__(self, job_name, job, config):
113113
self.job_name = job_name
@@ -214,10 +214,10 @@ def generate(self):
214214
return job_config, prow_config, None
215215

216216

217-
class E2ETest:
217+
class E2ETest(object):
218218

219219
def __init__(self, output_dir, job_name, job, config):
220-
self.env_filename = os.path.join(output_dir, '%s.env' % job_name)
220+
self.env_filename = os.path.join(output_dir, '%s.env' % job_name),
221221
self.job_name = job_name
222222
self.job = job
223223
self.common = config['common']

requirements.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
astroid==1.6.6
2+
backports.functools_lru_cache==1.5
3+
certifi==2019.6.16
4+
chardet==3.0.4
5+
configparser==3.8.1
6+
enum34==1.1.6
7+
google-cloud-bigquery==1.18.0
8+
google-cloud-pubsub==0.45.0
9+
idna==2.8
10+
influxdb==5.2.2
11+
isort==4.3.21
12+
jinja2==2.10.1
13+
lazy-object-proxy==1.4.1
14+
MarkupSafe==1.1.1
15+
mccabe==0.6.1
16+
pylint==1.9.4
17+
python-dateutil==2.8.0
18+
pytz==2019.2
19+
PyYAML==5.1.1
20+
requests==2.22.0
21+
ruamel.yaml==0.15.98
22+
setuptools==41.1.0
23+
sh==1.12.14
24+
singledispatch==3.4.0.3
25+
six==1.12.0
26+
urllib3==1.25.3
27+
webapp2==2.5.2
28+
wrapt==1.11.2

requirements2.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

requirements3.txt

Lines changed: 0 additions & 11 deletions
This file was deleted.

testgrid/conformance/upload_e2e.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#
3333
# Usage: see README.md
3434

35+
# Required for pylint: 1.9.4 to tokenize the python3 print function.
36+
from __future__ import print_function
3537

3638
import re
3739
import sys
@@ -110,7 +112,7 @@ def parse_e2e_logfile(file_handle, year):
110112
if passed is False:
111113
# if we already have found a failure, ignore subsequent pass/fails
112114
continue
113-
if E2E_LOG_SUCCESS_RE.match(line):
115+
elif E2E_LOG_SUCCESS_RE.match(line):
114116
passed = True
115117
elif E2E_LOG_FAIL_RE.match(line):
116118
passed = False

velodrome/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@py3_deps//:requirements.bzl", "requirement")
1+
load("@py_deps//:requirements.bzl", "requirement")
22

33
package(default_visibility = ["//visibility:public"])
44

0 commit comments

Comments
 (0)