Skip to content

Commit 916ae73

Browse files
committed
fix: linter fixes (#8)
1 parent 70a3f6b commit 916ae73

File tree

11 files changed

+88
-29
lines changed

11 files changed

+88
-29
lines changed

tensorflow_io/bigtable.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Copyright 2018 The TensorFlow Authors. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ==============================================================================
15+
"""Cloud Bigtable Client for TensorFlow.
16+
17+
This package allows TensorFlow to interface directly with Cloud Bigtable
18+
for high-speed data loading.
19+
20+
@@BigtableClient
21+
@@BigtableTable
22+
@@RowRange
23+
@@RowSet
24+
25+
26+
"""
27+
28+
29+
from tensorflow.python.util.all_util import remove_undocumented
30+
from tensorflow_io.python.ops.bigtable.bigtable_dataset_ops import BigtableClient
31+
from tensorflow_io.python.ops.bigtable.bigtable_dataset_ops import BigtableTable
32+
import tensorflow_io.python.ops.bigtable.bigtable_version_filters as filters
33+
import tensorflow_io.python.ops.bigtable.bigtable_row_set as row_set
34+
import tensorflow_io.python.ops.bigtable.bigtable_row_range as row_range
35+
36+
_allowed_symbols = [
37+
"BigtableClient",
38+
"BigtableTable",
39+
"filters",
40+
"row_set",
41+
"row_range",
42+
]
43+
44+
remove_undocumented(__name__, _allowed_symbols)

tensorflow_io/core/kernels/bigtable/bigtable_dataset_kernel.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ limitations under the License.
2222
#include "tensorflow/core/framework/op_kernel.h"
2323
#include "tensorflow/core/framework/resource_mgr.h"
2424
#include "tensorflow/core/framework/resource_op_kernel.h"
25-
#include "tensorflow_io/core/kernels/bigtable/serialization.h"
2625
#include "tensorflow_io/core/kernels/bigtable/bigtable_row_set.h"
2726
#include "tensorflow_io/core/kernels/bigtable/bigtable_version_filters.h"
27+
#include "tensorflow_io/core/kernels/bigtable/serialization.h"
2828

2929
namespace cbt = ::google::cloud::bigtable;
3030

@@ -117,7 +117,7 @@ class BigtableClientOp : public OpKernel {
117117

118118
~BigtableClientOp() { VLOG(1) << "BigtableClientOp dtor"; }
119119

120-
void Compute(OpKernelContext* ctx) override TF_LOCKS_EXCLUDED(mu_) {
120+
void Compute(OpKernelContext* ctx) override {
121121
VLOG(1) << "BigtableClientOp compute";
122122
ResourceMgr* mgr = ctx->resource_manager();
123123
ContainerInfo cinfo;
@@ -375,9 +375,9 @@ class BigtableDatasetOp : public DatasetOpKernel {
375375
GetResourceFromContext(ctx, "filter", &filter_resource));
376376
core::ScopedUnref filter_resource_unref_(filter_resource);
377377

378-
*output = new Dataset(ctx, client_resource->data_client(),
379-
row_set_resource->row_set(),
380-
filter_resource->filter(), table_id_, columns_, output_type_);
378+
*output = new Dataset(
379+
ctx, client_resource->data_client(), row_set_resource->row_set(),
380+
filter_resource->filter(), table_id_, columns_, output_type_);
381381
}
382382

383383
private:
@@ -513,7 +513,7 @@ class BigtableSplitRowSetEvenlyOp : public OpKernel {
513513
}
514514

515515
private:
516-
mutable mutex mu_;
516+
mutex mu_;
517517
std::string table_id_ GUARDED_BY(mu_);
518518
int num_splits_ GUARDED_BY(mu_);
519519
};

tensorflow_io/core/kernels/bigtable/bigtable_row_range.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class BigtableRowRangeOp
9090
}
9191

9292
private:
93-
mutable mutex mu_;
93+
mutex mu_;
9494
std::string left_row_key_ TF_GUARDED_BY(mu_);
9595
bool left_open_ TF_GUARDED_BY(mu_);
9696
std::string right_row_key_ TF_GUARDED_BY(mu_);

tensorflow_io/core/kernels/bigtable/bigtable_row_set.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class BigtableRowSetAppendRowRangeOp : public OpKernel {
102102
}
103103

104104
private:
105-
mutable mutex mu_;
105+
mutex mu_;
106106
std::string row_key_;
107107
};
108108

tensorflow_io/core/kernels/bigtable/bigtable_version_filters.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class BigtableLatestFilterOp
3535

3636
REGISTER_KERNEL_BUILDER(Name("BigtableLatestFilter").Device(DEVICE_CPU),
3737
BigtableLatestFilterOp);
38-
38+
3939
class BigtableTimestampRangeFilterOp
4040
: public AbstractBigtableResourceOp<BigtableFilterResource> {
4141
public:
@@ -48,7 +48,8 @@ class BigtableTimestampRangeFilterOp
4848

4949
private:
5050
StatusOr<BigtableFilterResource*> CreateResource() override {
51-
return new BigtableFilterResource(cbt::Filter::TimestampRangeMicros(start_ts_us_, end_ts_us_));
51+
return new BigtableFilterResource(
52+
cbt::Filter::TimestampRangeMicros(start_ts_us_, end_ts_us_));
5253
}
5354

5455
private:
@@ -82,5 +83,5 @@ class BigtablePrintFilterOp : public OpKernel {
8283
REGISTER_KERNEL_BUILDER(Name("BigtablePrintFilter").Device(DEVICE_CPU),
8384
BigtablePrintFilterOp);
8485

85-
} // namespace io
86-
} // namespace tensorflow
86+
} // namespace io
87+
} // namespace tensorflow

tensorflow_io/core/kernels/bigtable/bigtable_version_filters.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ limitations under the License.
2727
#include "tensorflow/core/framework/resource_op_kernel.h"
2828
#include "tensorflow_io/core/kernels/bigtable/bigtable_resource_kernel.h"
2929

30-
3130
namespace tensorflow {
3231
namespace io {
3332

@@ -56,7 +55,6 @@ class BigtableFilterResource : public ResourceBase {
5655
const google::cloud::bigtable::Filter filter_;
5756
};
5857

59-
6058
} // namespace io
6159
} // namespace tensorflow
6260

tensorflow_io/core/kernels/bigtable/serialization.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ limitations under the License.
1515
*/
1616

1717
#include "tensorflow_io/core/kernels/bigtable/serialization.h"
18+
1819
#include "rpc/xdr.h"
1920
#include "tensorflow/core/platform/errors.h"
2021
#include "tensorflow/core/platform/statusor.h"
@@ -72,9 +73,8 @@ inline StatusOr<bool_t> BytesToBool(std::string const& s) {
7273
return v;
7374
}
7475

75-
Status PutCellValueInTensor(Tensor& tensor, size_t index,
76-
DataType cell_type,
77-
google::cloud::bigtable::Cell const& cell) {
76+
Status PutCellValueInTensor(Tensor& tensor, size_t index, DataType cell_type,
77+
google::cloud::bigtable::Cell const& cell) {
7878
switch (cell_type) {
7979
case DT_STRING: {
8080
auto tensor_data = tensor.tensor<tstring, 1>();

tensorflow_io/python/ops/bigtable/__init__.py

Whitespace-only changes.

tensorflow_io/python/ops/bigtable/bigtable_dataset_ops.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ def parallel_read_rows(
7272
):
7373

7474
samples = core_ops.bigtable_split_row_set_evenly(
75-
self._client_resource, row_set._impl, self._table_id, num_parallel_calls,
75+
self._client_resource,
76+
row_set._impl,
77+
self._table_id,
78+
num_parallel_calls,
7679
)
7780

7881
def map_func(idx):

tests/test_bigtable/bigtable_emulator.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,15 @@ def _get_cbt_binary_path(env_var_name, search_paths, description):
4747
res = os.environ.get(env_var_name)
4848
if res is not None:
4949
if not os.path.isfile(res):
50-
raise EnvironmentError(
51-
(
52-
f"{description} specified in the {env_var_name} "
53-
"environment variable does not exist"
54-
)
50+
raise OSError(
51+
f"{description} specified in the {env_var_name} "
52+
"environment variable does not exist"
5553
)
5654
return res
5755
for candidate in search_paths:
5856
if os.path.isfile(candidate):
5957
return candidate
60-
raise EnvironmentError(f"Could not find {description}")
58+
raise OSError(f"Could not find {description}")
6159

6260

6361
def _get_cbt_emulator_path():

0 commit comments

Comments
 (0)