Skip to content

Commit 05d47fa

Browse files
authored
Remove rules_python dependency (#1810)
1 parent d0bea15 commit 05d47fa

23 files changed

+33
-72
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
run: |
2323
set -x -e
2424
git log --pretty -1
25-
sudo python3 -m pip install -U numpy
25+
sudo python3 -m pip install -U numpy black pyupgrade
2626
bazel run -s --verbose_failures --experimental_repo_remote_exec //tools/lint:check -- bazel pyupgrade black clang
2727
2828
lint-docs:

.github/workflows/reviewdog.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
steps:
1313
- uses: actions/checkout@v2
1414
- run: |
15-
sudo python3 -m pip install -U numpy pip
15+
sudo python3 -m pip install -U numpy pip black pyupgrade
1616
bazel run -s --verbose_failures --experimental_repo_remote_exec //tools/lint:lint -- bazel
1717
- uses: reviewdog/action-suggester@v1
1818
black:
@@ -21,7 +21,7 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@v2
2323
- run: |
24-
sudo python3 -m pip install -U numpy pip
24+
sudo python3 -m pip install -U numpy pip black pyupgrade
2525
bazel run -s --verbose_failures --experimental_repo_remote_exec //tools/lint:lint -- black
2626
- uses: reviewdog/action-suggester@v1
2727
clang:
@@ -30,7 +30,7 @@ jobs:
3030
steps:
3131
- uses: actions/checkout@v2
3232
- run: |
33-
sudo python3 -m pip install -U numpy pip
33+
sudo python3 -m pip install -U numpy pip black pyupgrade
3434
bazel run -s --verbose_failures --experimental_repo_remote_exec //tools/lint:lint -- clang
3535
- uses: reviewdog/action-suggester@v1
3636
pyupgrade:
@@ -39,6 +39,6 @@ jobs:
3939
steps:
4040
- uses: actions/checkout@v2
4141
- run: |
42-
sudo python3 -m pip install -U numpy pip
42+
sudo python3 -m pip install -U numpy pip black pyupgrade
4343
bazel run -s --verbose_failures --experimental_repo_remote_exec //tools/lint:lint -- pyupgrade
4444
- uses: reviewdog/action-suggester@v1

WORKSPACE

-21
Original file line numberDiff line numberDiff line change
@@ -91,27 +91,6 @@ switched_rules_by_language(
9191
grpc = True,
9292
)
9393

94-
# Note rules_python is placed earlier as tensorflow's version is older
95-
http_archive(
96-
name = "rules_python",
97-
sha256 = "aa96a691d3a8177f3215b14b0edc9641787abaaa30363a080165d06ab65e1161",
98-
urls = [
99-
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/rules_python/releases/download/0.0.1/rules_python-0.0.1.tar.gz",
100-
"https://github.com/bazelbuild/rules_python/releases/download/0.0.1/rules_python-0.0.1.tar.gz",
101-
],
102-
)
103-
104-
load("@rules_python//python:pip.bzl", "pip_import")
105-
106-
pip_import(
107-
name = "lint_dependencies",
108-
requirements = "//tools/lint:requirements.txt",
109-
)
110-
111-
load("@lint_dependencies//:requirements.bzl", "pip_install")
112-
113-
pip_install()
114-
11594
http_archive(
11695
name = "org_tensorflow",
11796
sha256 = "e58c939079588623e6fa1d054aec2f90f95018266e0a970fd353a5244f5173dc",

tensorflow_io/python/experimental/filter_ops.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ def gabor(
188188
1.0
189189
/ np.pi
190190
* np.sqrt(np.log(2) / 2.0)
191-
* (2.0 ** b + 1)
192-
/ (2.0 ** b - 1),
191+
* (2.0**b + 1)
192+
/ (2.0**b - 1),
193193
dtype.real_dtype,
194194
)
195195
/ freq
@@ -220,7 +220,7 @@ def gabor(
220220
rotx = y * tf.math.sin(theta) + x * tf.math.cos(theta)
221221
roty = y * tf.math.cos(theta) - x * tf.math.sin(theta)
222222

223-
g = tf.math.exp(-0.5 * (rotx ** 2 / sigma_x ** 2 + roty ** 2 / sigma_y ** 2))
223+
g = tf.math.exp(-0.5 * (rotx**2 / sigma_x**2 + roty**2 / sigma_y**2))
224224
g = g / (2 * np.pi * sigma_x * sigma_y)
225225
g = tf.cast(g, dtype) * tf.exp(
226226
tf.cast(1j, dtype) * tf.cast(2 * np.pi * freq * rotx + offset, dtype)

tensorflow_io/python/experimental/openexr_io_tensor_ops.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def __init__(self, filename, internal=False):
4444
shapes, dtypes, channels = core_ops.io_decode_exr_info(data)
4545
parts = []
4646
index = 0
47-
for (shape, dtypes, channels) in zip(
47+
for shape, dtypes, channels in zip(
4848
shapes.numpy(), dtypes.numpy(), channels.numpy()
4949
):
5050
# Remove trailing 0 from dtypes

tensorflow_io/python/experimental/serialization_ops.py

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import tensorflow as tf
2020
from tensorflow_io.python.ops import core_ops
2121

22+
2223
# _NamedTensorSpec allows adding a `named` key while traversing,
2324
# so that it is possible to build up the `/R/Foo` JSON Pointers.
2425
class _NamedTensorSpec(tf.TensorSpec):

tensorflow_io/python/ops/arrow_io_tensor_ops.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ def _extract_table_arrays(table):
8383
# Pad buffer addrs, sizes and array lengths so inputs are rectangular
8484
num_columns = len(array_buffer_sizes)
8585
for i in range(num_columns):
86-
8786
# pad chunk list with empty lists that will be padded with null bufs
8887
if len(array_buffer_sizes[i]) < max_num_chunks:
8988
array_buffer_sizes[i].extend(
@@ -94,7 +93,6 @@ def _extract_table_arrays(table):
9493

9594
num_chunks = len(array_buffer_sizes[i])
9695
for j in range(num_chunks):
97-
9896
# pad buffer addr, size, and array length lists
9997
if len(array_buffer_sizes[i][j]) < max_num_bufs:
10098
array_buffer_sizes[i][j].extend(
@@ -140,7 +138,6 @@ def wrap_func(inp):
140138
def init_resource_op(self, table):
141139
"""Initialize the resource op with a pyarrow.Table"""
142140
with tf.name_scope("ArrowIOTensor") as scope:
143-
144141
# Serialize the schema to send to the kernel
145142
schema_buffer = table.schema.serialize()
146143

@@ -241,7 +238,6 @@ class ArrowIOTensor(io_tensor_ops._TableIOTensor): # pylint: disable=protected-
241238
# Constructor (private)
242239
# =============================================================================
243240
def __init__(self, table, spec=None, internal=False):
244-
245241
# Get or build a new ArrowIOResource
246242
if isinstance(table, ArrowIOResource):
247243
arrow_resource = table
@@ -292,7 +288,7 @@ def __init__(self, table, spec=None, internal=False):
292288
]
293289

294290
shapes = []
295-
for (column_index, column) in columns:
291+
for column_index, column in columns:
296292
shape, _ = core_ops.io_arrow_readable_spec(
297293
resource, column_index, column
298294
)
@@ -306,7 +302,7 @@ def __init__(self, table, spec=None, internal=False):
306302
]
307303

308304
elements = []
309-
for ((column_index, column), entry, shape) in zip(columns, entries, shapes):
305+
for (column_index, column), entry, shape in zip(columns, entries, shapes):
310306
function = _ArrowIOTensorComponentFunction(
311307
core_ops.io_arrow_readable_read,
312308
resource,

tensorflow_io/python/ops/avro_dataset_ops.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def __init__(self, filename, schema, columns=None, internal=True):
7575
)
7676
columns_function.append(function)
7777

78-
for (column, function) in zip(columns, columns_function):
78+
for column, function in zip(columns, columns_function):
7979
column_dataset = tf.compat.v2.data.Dataset.range(
8080
0, sys.maxsize, capacity
8181
)

tensorflow_io/python/ops/data_ops.py

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import tensorflow as tf
1818

19+
1920
# Note: BaseDataset could be used by Dataset implementations
2021
# that does not utilize DataInput implementation.
2122
class BaseDataset(tf.compat.v2.data.Dataset):

tensorflow_io/python/ops/json_dataset_ops.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def __init__(self, filename, columns=None, mode=None, internal=True):
7575
)
7676
columns_function.append(function)
7777

78-
for (column, function) in zip(columns, columns_function):
78+
for column, function in zip(columns, columns_function):
7979
column_dataset = tf.compat.v2.data.Dataset.range(
8080
0, sys.maxsize, capacity
8181
)

tensorflow_io/python/ops/orc_dataset_ops.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def __init__(self, filename, columns=None, internal=True, **kwargs):
6969
)
7070
columns_function.append(function)
7171

72-
for (column, function) in zip(columns, columns_function):
72+
for column, function in zip(columns, columns_function):
7373
column_dataset = tf.compat.v2.data.Dataset.range(
7474
0, sys.maxsize, capacity
7575
)

tensorflow_io/python/ops/prometheus_dataset_ops.py

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def __init__(
5656
)
5757
spec_by_job[instance] = spec_by_instance
5858
spec[job] = spec_by_job
59+
5960
# Map spec to entries of 3 tuple (job, instance, name)
6061
class MetricEntry:
6162
def __init__(self, job, instance, name):

tests/test_arrow.py

-2
Original file line numberDiff line numberDiff line change
@@ -378,10 +378,8 @@ def evaluate_result(value):
378378

379379
# Iterate over the dataset
380380
for results in dataset:
381-
382381
# For batches, iterate over each row in batch or remainder at end
383382
for result_idx in range(batch_size or 1):
384-
385383
# Get a single row value
386384
if batch_size is None:
387385
value = [r.numpy() for r in results]

tests/test_atds_avro/utils/stat_t_test_cli.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,13 @@ def run_welchs_ttest(stat1, stat2, alpha, faster):
139139
df1 = n1 - 1 # degree of freedom of stat1
140140
df2 = n2 - 1 # degree of freedom of stat2
141141

142-
sample_v1 = s1 ** 2 / n1 # biased estimated sample variance of stat1
143-
sample_v2 = s2 ** 2 / n2 # biased estimated sample variance of stat2
142+
sample_v1 = s1**2 / n1 # biased estimated sample variance of stat1
143+
sample_v2 = s2**2 / n2 # biased estimated sample variance of stat2
144144

145145
biased_variance = np.sqrt(sample_v1 + sample_v2)
146146
# degree of freedom
147147
df = (sample_v1 + sample_v2) ** 2 / (
148-
sample_v1 ** 2 / (df1) + sample_v2 ** 2 / (df2)
148+
sample_v1**2 / (df1) + sample_v2**2 / (df2)
149149
)
150150

151151
mean_delta = m1 - m2

tests/test_audio.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def test_audio_io_tensor_24(audio_data_24, io_tensor_func):
7777
for step in [1, 100, 101, 200, 501, 600, 1001, 2000, 5001]:
7878
indices = list(range(0, 14336, step))
7979
# TODO: -1 vs. 14336 might need fix
80-
for (start, stop) in zip(indices, indices[1:] + [14336]):
80+
for start, stop in zip(indices, indices[1:] + [14336]):
8181
audio_tensor_value = audio_tensor[start:stop]
8282
audio_value_value = audio_value[start:stop]
8383
assert audio_tensor_value.shape == audio_value_value.shape
@@ -139,7 +139,7 @@ def test_audio_io_tensor(audio_data, io_tensor_func):
139139
for step in [1, 100, 101, 200, 501, 600, 1001, 2000, 5001]:
140140
indices = list(range(0, 5760, step))
141141
# TODO: -1 vs. 5760 might need fix
142-
for (start, stop) in zip(indices, indices[1:] + [5760]):
142+
for start, stop in zip(indices, indices[1:] + [5760]):
143143
audio_tensor_value = audio_tensor[start:stop]
144144
audio_value_value = audio_value[start:stop]
145145
assert audio_tensor_value.shape == audio_value_value.shape
@@ -218,7 +218,7 @@ def func(filename, position):
218218
dataset = dataset.map(func, num_parallel_calls=num_parallel_calls)
219219

220220
item = 0
221-
for (data, rate) in dataset:
221+
for data, rate in dataset:
222222
assert audio_rate == rate
223223
assert data.shape == (100, 1)
224224
position = 1000 if item == 0 else 2000

tests/test_azure.py

-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ class AZFSTest(tf.test.TestCase, AZFSTestBase):
206206
"""Run tests for azfs backend using account key authentication."""
207207

208208
def __init__(self, methodName="runTest"): # pylint: disable=invalid-name
209-
210209
self.account = "devstoreaccount1"
211210
self.container = "aztest"
212211
self.path_root = "az://" + os.path.join(self.account, self.container)

tests/test_http.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def test_gfile_read(local_content, remote_filename):
7777
assert remote_gfile.size() == len(local_content)
7878
offset_start = list(range(0, len(local_content), 100))
7979
offset_stop = offset_start[1:] + [len(local_content)]
80-
for (start, stop) in zip(offset_start, offset_stop):
80+
for start, stop in zip(offset_start, offset_stop):
8181
assert remote_gfile.read(100) == local_content[start:stop]
8282

8383

tests/test_json.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def test_io_tensor_json_recods_mode():
6161
dataset = tf.data.Dataset.zip((feature_dataset, label_dataset))
6262

6363
i = 0
64-
for (j_x, j_y) in dataset:
64+
for j_x, j_y in dataset:
6565
v_x = x_test[i]
6666
v_y = y_test[i]
6767
for index, x in enumerate(j_x):
@@ -123,7 +123,7 @@ def test_io_tensor_json():
123123
dataset = tf.data.Dataset.zip((feature_dataset, label_dataset))
124124

125125
i = 0
126-
for (j_x, j_y) in dataset:
126+
for j_x, j_y in dataset:
127127
v_x = x_test[i]
128128
v_y = y_test[i]
129129
for index, x in enumerate(j_x):
@@ -158,7 +158,7 @@ def test_json_dataset():
158158
dataset = tf.data.Dataset.zip((feature_dataset, label_dataset))
159159

160160
i = 0
161-
for (j_x, j_y) in dataset:
161+
for j_x, j_y in dataset:
162162
v_x = x_test[i]
163163
v_y = y_test[i]
164164
for index, x in enumerate(j_x):

tests/test_ossfs.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ def test_walk_in_order(self):
359359
all_dirs = []
360360
all_subdirs = []
361361
all_files = []
362-
for (w_dir, w_subdirs, w_files) in file_io.walk(dir_path, in_order=True):
362+
for w_dir, w_subdirs, w_files in file_io.walk(dir_path, in_order=True):
363363
all_dirs.append(w_dir)
364364
all_subdirs.append(w_subdirs)
365365
all_files.append(w_files)
@@ -388,7 +388,7 @@ def test_walk_post_order(self):
388388
all_dirs = []
389389
all_subdirs = []
390390
all_files = []
391-
for (w_dir, w_subdirs, w_files) in file_io.walk(dir_path, in_order=False):
391+
for w_dir, w_subdirs, w_files in file_io.walk(dir_path, in_order=False):
392392
all_dirs.append(w_dir)
393393
all_subdirs.append(w_subdirs)
394394
all_files.append(w_files)
@@ -416,7 +416,7 @@ def test_walk_failure(self):
416416
all_dirs = []
417417
all_subdirs = []
418418
all_files = []
419-
for (w_dir, w_subdirs, w_files) in file_io.walk(dir_path, in_order=False):
419+
for w_dir, w_subdirs, w_files in file_io.walk(dir_path, in_order=False):
420420
all_dirs.append(w_dir)
421421
all_subdirs.append(w_subdirs)
422422
all_files.append(w_files)

tests/test_parse_avro.py

-3
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ def _assert_equal(expected, actual):
223223
_assert_equal(expected, actual)
224224

225225
def _verify_output(self, expected_data, actual_dataset):
226-
227226
next_data = iter(actual_dataset)
228227

229228
for expected in expected_data:
@@ -286,7 +285,6 @@ def test_inval_num_parallel_calls(self):
286285
)
287286

288287
with pytest.raises(ValueError):
289-
290288
dataset_a = tfio.experimental.columnar.AvroRecordDataset(
291289
filenames=filenames,
292290
num_parallel_reads=NUM_PARALLEL_READS,
@@ -295,7 +293,6 @@ def test_inval_num_parallel_calls(self):
295293
)
296294

297295
with pytest.raises(ValueError):
298-
299296
dataset_b = tfio.experimental.columnar.AvroRecordDataset(
300297
filenames=filenames,
301298
num_parallel_reads=NUM_PARALLEL_READS,

tests/test_pulsar.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def test_pulsar_keyed_messages():
6666
timeout=default_pulsar_timeout,
6767
)
6868
kv = dict()
69-
for (msg, key) in dataset:
69+
for msg, key in dataset:
7070
kv.setdefault(key.numpy().decode(), []).append(msg.numpy())
7171
assert kv["K0"] == [("D" + str(i)).encode() for i in range(0, 6, 2)]
7272
assert kv["K1"] == [("D" + str(i)).encode() for i in range(1, 6, 2)]
@@ -232,7 +232,7 @@ def test_pulsar_write_keyed_messages():
232232
timeout=default_pulsar_timeout,
233233
)
234234
kv = dict()
235-
for (msg, key) in dataset:
235+
for msg, key in dataset:
236236
kv.setdefault(key.numpy().decode(), []).append(msg.numpy())
237237
assert kv["0"] == [("msg-" + str(i)).encode() for i in range(0, 10, 3)]
238238
assert kv["1"] == [("msg-" + str(i)).encode() for i in range(1, 10, 3)]

tests/test_text/stdin_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ def f(v):
3333

3434
text_dataset = text_io.TextDataset("file://-").map(f)
3535

36-
for (frame_number_value, ip_dst_value, ip_proto_value) in text_dataset:
36+
for frame_number_value, ip_dst_value, ip_proto_value in text_dataset:
3737
print(ip_dst_value.numpy())

0 commit comments

Comments
 (0)