Skip to content

Testing/Build Workflows #266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d091052
add testing workflow
aktech Oct 2, 2024
867f1a5
single python
aktech Oct 2, 2024
3bac60c
trigger
aktech Oct 2, 2024
87d8bfe
install in build job
aktech Oct 2, 2024
0d8c14b
install pytest
aktech Oct 2, 2024
619e800
install test dependencies
aktech Oct 2, 2024
dfa6ea2
add xfail to tests
aktech Oct 2, 2024
bb45d3f
add reusable workflows and add pr number in xfail
aktech Oct 2, 2024
d0a177a
fix composite action
aktech Oct 2, 2024
eae0818
add more xfails
aktech Oct 2, 2024
1e4d94c
xfail top_k_uniques_stats_generator_test.py
aktech Oct 2, 2024
1f1c584
xfails in partitioned_stats_generator_test.py
aktech Oct 2, 2024
53beec9
more xfails
aktech Oct 2, 2024
d39ccbd
add missing imports
aktech Oct 2, 2024
57c1e5b
fix extra decorators
aktech Oct 4, 2024
da5b290
more xfails
aktech Oct 4, 2024
703684a
Merge branch 'master' into testing-workflow
aktech Oct 4, 2024
ec7c05b
use xfail instead of skip
aktech Oct 4, 2024
94c6af2
remove xfails that are passing
aktech Oct 4, 2024
ec0e02a
dont run xfail + add test deps
aktech Oct 7, 2024
5f41842
fix build failure by pinning tensorflow_metadata
andrewfulton9 May 8, 2025
7438b3c
update setup.py to current build
andrewfulton9 May 8, 2025
3c4ad2f
move test requirements
andrewfulton9 May 30, 2025
30cb356
debugging
andrewfulton9 May 30, 2025
61ddf2e
more debugging
andrewfulton9 May 30, 2025
b8d4c23
remove upload for testing
andrewfulton9 May 30, 2025
15df140
add environment variable to build nightly
andrewfulton9 May 30, 2025
f63c409
add extra-index-url
andrewfulton9 May 30, 2025
2b4c5c2
trying to use nightly install
andrewfulton9 May 30, 2025
9cb79b3
revert debugging changes
andrewfulton9 Jun 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/reusable-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Resusable steps to build data-validation

inputs:
python-version:
description: 'Python version'
required: true
upload-artifact:
description: 'Should upload build artifact or not'
default: false

runs:
using: 'composite'
steps:
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}

- name: Build the package for Python ${{ inputs.python-version }}
shell: bash
run: |
version="${{ matrix.python-version }}"
docker compose run -e PYTHON_VERSION=$(echo "$version" | sed 's/\.//') manylinux2010

- name: Upload wheel artifact for Python ${{ matrix.python-version }}
if: ${{ inputs.upload-artifact == 'true' }}
uses: actions/upload-artifact@v3
with:
name: data-validation-wheel-py${{ matrix.python-version }}
path: dist/*.whl

- name: Install built wheel
shell: bash
run: |
pip install twine
twine check dist/*
pip install dist/*.whl
54 changes: 54 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build

on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Build data-validation
id: build-data-validation
uses: ./.github/reusable-build
with:
python-version: ${{ matrix.python-version }}
upload-artifact: true

upload_to_pypi:
name: Upload to PyPI
runs-on: ubuntu-latest
if: (github.event_name == 'release' && startsWith(github.ref, 'refs/tags')) || (github.event_name == 'workflow_dispatch')
needs: [build]
environment:
name: pypi
url: https://pypi.org/p/tensorflow-data-validation/
permissions:
id-token: write
steps:
- name: Retrieve wheels
uses: actions/download-artifact@v4.1.8
with:
merge-multiple: true
path: wheels

- name: List the build artifacts
run: |
ls -lAs wheels/

- name: Upload to PyPI
uses: pypa/gh-action-pypi-publish@release/v1.9
with:
packages_dir: wheels/
38 changes: 38 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Test

on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Build data-validation
id: build-data-validation
uses: ./.github/reusable-build
with:
python-version: ${{ matrix.python-version }}

- name: Install built wheel
shell: bash
run: |
pip install dist/*.whl['test']

- name: Run Test
run: |
rm -rf bazel-*
# run tests
pytest -vv
31 changes: 19 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,27 +182,33 @@ def select_constraint(default, nightly=None, git_master=None):
'joblib>=1.2.0', # Dependency for multi-processing.
'numpy>=1.22.0',
'pandas>=1.0,<2',
'protobuf>=4.25.2,<5;python_version>="3.11"',
'protobuf>=4.25.2,<6;python_version>="3.11"',
'protobuf>=3.20.3,<5;python_version<"3.11"',
'pyarrow>=10,<11',
'pyfarmhash>=0.2.2,<0.4',
'six>=1.12,<2',
'tensorflow' + select_constraint(
default='>=2.16,<2.17',
nightly='>=2.17.0.dev',
git_master='@git+https://github.com/tensorflow/tensorflow@master'),
'tensorflow-metadata' + select_constraint(
default='>=1.16.0,<1.17',
'tensorflow>=2.17,<2.18',
'tensorflow-metadata'
+ select_constraint(
default='>=1.16.1,<1.17',
nightly='>=1.17.0.dev',
git_master='@git+https://github.com/tensorflow/metadata@master'),
'tfx-bsl' + select_constraint(
default='>=1.16.0,<1.17',
git_master='@git+https://github.com/tensorflow/metadata@master',
),
'tfx-bsl'
+ select_constraint(
default='>=1.16.1,<1.17',
nightly='>=1.17.0.dev',
git_master='@git+https://github.com/tensorflow/tfx-bsl@master'),
git_master='@git+https://github.com/tensorflow/tfx-bsl@master',
),
],
extras_require={
'mutual-information': _make_mutual_information_requirements(),
'visualization': _make_visualization_requirements(),
'test': [
"pytest",
"scikit-learn",
"scipy",
],
'all': _make_all_extra_requirements(),
},
python_requires='>=3.9,<4',
Expand All @@ -222,4 +228,5 @@ def select_constraint(default, nightly=None, git_master=None):
'install': _InstallPlatlibCommand,
'build': _BuildCommand,
'bazel_build': _BazelBuildCommand,
})
},
)
6 changes: 6 additions & 0 deletions tensorflow_data_validation/api/stats_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from __future__ import print_function

import os
import pytest
import tempfile
from absl.testing import absltest
import apache_beam as beam
Expand All @@ -43,6 +44,7 @@ class StatsAPITest(absltest.TestCase):
def _get_temp_dir(self):
return tempfile.mkdtemp()

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

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

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

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

class MergeDatasetFeatureStatisticsListTest(absltest.TestCase):

@pytest.mark.xfail(run=False, reason="PR 260 This test fails and needs to be fixed.")
def test_merges_two_shards(self):
stats1 = text_format.Parse(
"""
Expand Down
10 changes: 10 additions & 0 deletions tensorflow_data_validation/api/validation_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from __future__ import print_function

import os
import pytest
import tempfile

from absl.testing import absltest
Expand Down Expand Up @@ -3172,6 +3173,14 @@ class IdentifyAnomalousExamplesTest(parameterized.TestCase):
@parameterized.named_parameters(*IDENTIFY_ANOMALOUS_EXAMPLES_VALID_INPUTS)
def test_identify_anomalous_examples(self, examples, schema_text,
expected_result):

if self._testMethodName in [
"test_identify_anomalous_examples_same_anomaly_reason",
"test_identify_anomalous_examples_no_anomalies",
"test_identify_anomalous_examples_different_anomaly_reasons"
]:
pytest.xfail(reason="PR 260 This test fails and needs to be fixed. ")

schema = text_format.Parse(schema_text, schema_pb2.Schema())
options = stats_options.StatsOptions(schema=schema)

Expand Down Expand Up @@ -3232,6 +3241,7 @@ def _assert_skew_pairs_equal(self, actual, expected) -> None:
for each in actual:
self.assertIn(each, expected)

@pytest.mark.xfail(run=False, reason="PR 260 This test fails and needs to be fixed.")
def test_detect_feature_skew(self):
training_data = [
text_format.Parse("""
Expand Down
7 changes: 2 additions & 5 deletions tensorflow_data_validation/coders/csv_decoder_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from __future__ import print_function

import sys
from absl.testing import absltest
import pytest
from absl.testing import parameterized
import apache_beam as beam
from apache_beam.testing import util
Expand Down Expand Up @@ -366,6 +366,7 @@
]


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

Expand Down Expand Up @@ -405,7 +406,3 @@ def test_csv_decoder_invalid_row(self):
| csv_decoder.DecodeCSV(column_names=column_names))
util.assert_that(
result, test_util.make_arrow_record_batches_equal_fn(self, None))


if __name__ == '__main__':
absltest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from __future__ import print_function

import copy
import pytest
import os

from absl import flags
Expand Down Expand Up @@ -1737,6 +1738,7 @@
]


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

@classmethod
Expand Down Expand Up @@ -1787,7 +1789,6 @@ def _assert_features_equal(lhs, rhs):
rhs_schema_copy.ClearField('feature')
self.assertEqual(lhs_schema_copy, rhs_schema_copy)
_assert_features_equal(lhs, rhs)

@parameterized.named_parameters(*_TEST_CASES)
def test_e2e(self, stats_options, expected_stats_pbtxt,
expected_inferred_schema_pbtxt, schema_for_validation_pbtxt,
Expand Down
Loading