Skip to content

Commit 58af9e7

Browse files
committed
Prepare code for breaking change in Protobuf C++ API.
Protobuf 6.30.0 will change the return types of Descriptor::name() and other methods to absl::string_view. This makes the code work both before and after such a change. PiperOrigin-RevId: 689135228
1 parent d3710e6 commit 58af9e7

22 files changed

+8
-306
lines changed

.github/reusable-build/action.yml

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

.github/workflows/build.yml

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

.github/workflows/test.yml

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

tensorflow_data_validation/anomalies/schema.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,15 +1032,15 @@ void Schema::UpdateFeatureInternal(
10321032
->FindValueByNumber(view.type());
10331033
string data_type_name = (descriptor == nullptr)
10341034
? absl::StrCat("unknown(", view.type(), ")")
1035-
: descriptor->name();
1035+
: std::string(descriptor->name());
10361036

10371037
const google::protobuf::EnumValueDescriptor* schema_descriptor =
10381038
tensorflow::metadata::v0::FeatureType_descriptor()->FindValueByNumber(
10391039
feature->type());
10401040
string schema_type_name =
10411041
(schema_descriptor == nullptr)
10421042
? absl::StrCat("unknown(", feature->type(), ")")
1043-
: schema_descriptor->name();
1043+
: std::string(schema_descriptor->name());
10441044
descriptions->push_back(
10451045
{tensorflow::metadata::v0::AnomalyInfo::UNEXPECTED_DATA_TYPE,
10461046
"Unexpected data type",

tensorflow_data_validation/api/stats_api_test.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from __future__ import print_function
2020

2121
import os
22-
import pytest
2322
import tempfile
2423
from absl.testing import absltest
2524
import apache_beam as beam
@@ -44,7 +43,6 @@ class StatsAPITest(absltest.TestCase):
4443
def _get_temp_dir(self):
4544
return tempfile.mkdtemp()
4645

47-
@pytest.mark.xfail(run=False, reason="PR 260 This test fails and needs to be fixed.")
4846
def test_stats_pipeline(self):
4947
record_batches = [
5048
pa.RecordBatch.from_arrays([
@@ -203,7 +201,6 @@ def test_stats_pipeline(self):
203201
}
204202
""", statistics_pb2.DatasetFeatureStatisticsList())
205203

206-
@pytest.mark.xfail(run=False, reason="PR 260 This test fails and needs to be fixed.")
207204
def test_stats_pipeline_with_examples_with_no_values(self):
208205
record_batches = [
209206
pa.RecordBatch.from_arrays([
@@ -321,7 +318,6 @@ def test_stats_pipeline_with_examples_with_no_values(self):
321318
test_util.make_dataset_feature_stats_list_proto_equal_fn(
322319
self, expected_result, check_histograms=False))
323320

324-
@pytest.mark.xfail(run=False, reason="PR 260 This test fails and needs to be fixed.")
325321
def test_stats_pipeline_with_zero_examples(self):
326322
expected_result = text_format.Parse(
327323
"""
@@ -343,7 +339,6 @@ def test_stats_pipeline_with_zero_examples(self):
343339
test_util.make_dataset_feature_stats_list_proto_equal_fn(
344340
self, expected_result, check_histograms=False))
345341

346-
@pytest.mark.xfail(run=False, reason="PR 260 This test fails and needs to be fixed.")
347342
def test_stats_pipeline_with_sample_rate(self):
348343
record_batches = [
349344
pa.RecordBatch.from_arrays(
@@ -493,7 +488,6 @@ def test_write_stats_to_tfrecord_and_binary(self):
493488

494489
class MergeDatasetFeatureStatisticsListTest(absltest.TestCase):
495490

496-
@pytest.mark.xfail(run=False, reason="PR 260 This test fails and needs to be fixed.")
497491
def test_merges_two_shards(self):
498492
stats1 = text_format.Parse(
499493
"""

tensorflow_data_validation/api/validation_api_test.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from __future__ import print_function
2121

2222
import os
23-
import pytest
2423
import tempfile
2524

2625
from absl.testing import absltest
@@ -3173,14 +3172,6 @@ class IdentifyAnomalousExamplesTest(parameterized.TestCase):
31733172
@parameterized.named_parameters(*IDENTIFY_ANOMALOUS_EXAMPLES_VALID_INPUTS)
31743173
def test_identify_anomalous_examples(self, examples, schema_text,
31753174
expected_result):
3176-
3177-
if self._testMethodName in [
3178-
"test_identify_anomalous_examples_same_anomaly_reason",
3179-
"test_identify_anomalous_examples_no_anomalies",
3180-
"test_identify_anomalous_examples_different_anomaly_reasons"
3181-
]:
3182-
pytest.xfail(reason="PR 260 This test fails and needs to be fixed. ")
3183-
31843175
schema = text_format.Parse(schema_text, schema_pb2.Schema())
31853176
options = stats_options.StatsOptions(schema=schema)
31863177

@@ -3241,7 +3232,6 @@ def _assert_skew_pairs_equal(self, actual, expected) -> None:
32413232
for each in actual:
32423233
self.assertIn(each, expected)
32433234

3244-
@pytest.mark.xfail(run=False, reason="PR 260 This test fails and needs to be fixed.")
32453235
def test_detect_feature_skew(self):
32463236
training_data = [
32473237
text_format.Parse("""

tensorflow_data_validation/coders/csv_decoder_test.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from __future__ import print_function
2222

2323
import sys
24-
import pytest
24+
from absl.testing import absltest
2525
from absl.testing import parameterized
2626
import apache_beam as beam
2727
from apache_beam.testing import util
@@ -366,7 +366,6 @@
366366
]
367367

368368

369-
@pytest.mark.xfail(run=False, reason="PR 260 This test fails and needs to be fixed. ")
370369
class CSVDecoderTest(parameterized.TestCase):
371370
"""Tests for CSV decoder."""
372371

@@ -406,3 +405,7 @@ def test_csv_decoder_invalid_row(self):
406405
| csv_decoder.DecodeCSV(column_names=column_names))
407406
util.assert_that(
408407
result, test_util.make_arrow_record_batches_equal_fn(self, None))
408+
409+
410+
if __name__ == '__main__':
411+
absltest.main()

tensorflow_data_validation/integration_tests/sequence_example_e2e_test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from __future__ import print_function
1919

2020
import copy
21-
import pytest
2221
import os
2322

2423
from absl import flags
@@ -1738,7 +1737,6 @@
17381737
]
17391738

17401739

1741-
@pytest.mark.xfail(run=False, reason="PR 260 This test fails and needs to be fixed. ")
17421740
class SequenceExampleStatsTest(parameterized.TestCase):
17431741

17441742
@classmethod
@@ -1789,6 +1787,7 @@ def _assert_features_equal(lhs, rhs):
17891787
rhs_schema_copy.ClearField('feature')
17901788
self.assertEqual(lhs_schema_copy, rhs_schema_copy)
17911789
_assert_features_equal(lhs, rhs)
1790+
17921791
@parameterized.named_parameters(*_TEST_CASES)
17931792
def test_e2e(self, stats_options, expected_stats_pbtxt,
17941793
expected_inferred_schema_pbtxt, schema_for_validation_pbtxt,

tensorflow_data_validation/skew/feature_skew_detector_test.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
import traceback
1717

18-
import pytest
1918
from absl.testing import absltest
2019
from absl.testing import parameterized
2120
import apache_beam as beam
@@ -142,7 +141,6 @@ def _make_ex(identifier: str,
142141

143142
class FeatureSkewDetectorTest(parameterized.TestCase):
144143

145-
@pytest.mark.xfail(run=False, reason="PR 260 This test fails and needs to be fixed.")
146144
def test_detect_feature_skew(self):
147145
baseline_examples, test_examples, _ = get_test_input(
148146
include_skewed_features=True, include_close_floats=True)
@@ -194,7 +192,6 @@ def test_detect_feature_skew(self):
194192
skew_result,
195193
test_util.make_skew_result_equal_fn(self, expected_result))
196194

197-
@pytest.mark.xfail(run=False, reason="PR 260 This test fails and needs to be fixed.")
198195
def test_detect_no_skew(self):
199196
baseline_examples, test_examples, _ = get_test_input(
200197
include_skewed_features=False, include_close_floats=False)
@@ -224,7 +221,6 @@ def test_detect_no_skew(self):
224221
util.assert_that(skew_sample, make_sample_equal_fn(self, 0, []),
225222
'CheckSkewSample')
226223

227-
@pytest.mark.xfail(run=False, reason="PR 260 This test fails and needs to be fixed.")
228224
def test_obtain_skew_sample(self):
229225
baseline_examples, test_examples, skew_pairs = get_test_input(
230226
include_skewed_features=True, include_close_floats=False)
@@ -248,7 +244,6 @@ def test_obtain_skew_sample(self):
248244
skew_sample, make_sample_equal_fn(self, sample_size,
249245
potential_samples))
250246

251-
@pytest.mark.xfail(run=False, reason="PR 260 This test fails and needs to be fixed.")
252247
def test_empty_inputs(self):
253248
baseline_examples, test_examples, _ = get_test_input(
254249
include_skewed_features=True, include_close_floats=True)
@@ -304,7 +299,6 @@ def test_empty_inputs(self):
304299
make_sample_equal_fn(self, 0, expected_result),
305300
'CheckSkewSample')
306301

307-
@pytest.mark.xfail(run=False, reason="PR 260 This test fails and needs to be fixed.")
308302
def test_float_precision_configuration(self):
309303
baseline_examples, test_examples, _ = get_test_input(
310304
include_skewed_features=True, include_close_floats=True)
@@ -395,7 +389,6 @@ def test_no_identifier_features(self):
395389
_ = ((baseline_examples, test_examples)
396390
| feature_skew_detector.DetectFeatureSkewImpl([]))
397391

398-
@pytest.mark.xfail(run=False, reason="PR 260 This test fails and needs to be fixed.")
399392
def test_duplicate_identifiers_allowed_with_duplicates(self):
400393
base_example_1 = text_format.Parse(
401394
"""
@@ -469,7 +462,6 @@ def test_duplicate_identifiers_allowed_with_duplicates(self):
469462
skew_result,
470463
test_util.make_skew_result_equal_fn(self, expected_result))
471464

472-
@pytest.mark.xfail(run=False, reason="PR 260 This test fails and needs to be fixed.")
473465
def test_duplicate_identifiers_not_allowed_with_duplicates(self):
474466
base_example_1 = text_format.Parse(
475467
"""
@@ -535,7 +527,6 @@ def test_duplicate_identifiers_not_allowed_with_duplicates(self):
535527
self.assertLen(actual_counter, 1)
536528
self.assertEqual(actual_counter[0].committed, 1)
537529

538-
@pytest.mark.xfail(run=False, reason="PR 260 This test fails and needs to be fixed.")
539530
def test_skips_missing_identifier_example(self):
540531
base_example_1 = text_format.Parse(
541532
"""
@@ -576,7 +567,6 @@ def test_skips_missing_identifier_example(self):
576567
runner = p.run()
577568
runner.wait_until_finish()
578569

579-
@pytest.mark.xfail(run=False, reason="PR 260 This test fails and needs to be fixed.")
580570
def test_empty_features_equivalent(self):
581571
base_example_1 = text_format.Parse(
582572
"""
@@ -626,7 +616,6 @@ def test_empty_features_equivalent(self):
626616
runner = p.run()
627617
runner.wait_until_finish()
628618

629-
@pytest.mark.xfail(run=False, reason="PR 260 This test fails and needs to be fixed.")
630619
def test_empty_features_not_equivalent_to_missing(self):
631620
base_example_1 = text_format.Parse(
632621
"""
@@ -699,7 +688,6 @@ def test_telemetry(self):
699688
self.assertLen(actual_counter, 1)
700689
self.assertEqual(actual_counter[0].committed, 1)
701690

702-
@pytest.mark.xfail(run=False, reason="PR 260 This test fails and needs to be fixed.")
703691
def test_confusion_analysis(self):
704692

705693
baseline_examples = [
@@ -834,7 +822,6 @@ def test_confusion_analysis_errors(self, input_example, expected_error_regex):
834822
feature_skew_detector.ConfusionConfig(name='val'),
835823
]))[feature_skew_detector.CONFUSION_KEY]
836824

837-
@pytest.mark.xfail(run=False, reason="PR 260 This test fails and needs to be fixed.")
838825
def test_match_stats(self):
839826
baseline_examples = [
840827
_make_ex('id0'),

0 commit comments

Comments
 (0)