-
Notifications
You must be signed in to change notification settings - Fork 715
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
Extend tfxio factory to use parquet-tfxio #4761
Merged
copybara-service
merged 7 commits into
tensorflow:master
from
martinbomio:parquet-tfxio-support
Jun 8, 2022
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c9b34af
Extend tfxio factory to use parquet-tfxio
martinbomio 5ac2ff2
Add parquet file format
martinbomio 3913c44
Address PR comments
martinbomio 30bec96
More PR suggestions
martinbomio 3bdccaf
Rename parquet file format enum
martinbomio 35bfd1f
Add future annotations to support proto enum typing
martinbomio 035e3cf
Disable max line limit in protolint for comment
martinbomio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
from tfx.proto import example_gen_pb2 | ||
from tfx.types import standard_artifacts | ||
from tfx_bsl.coders import tf_graph_record_decoder | ||
from tfx_bsl.tfxio import parquet_tfxio | ||
from tfx_bsl.tfxio import raw_tf_record | ||
from tfx_bsl.tfxio import record_based_tfxio | ||
from tfx_bsl.tfxio import record_to_tensor_tfxio | ||
|
@@ -70,6 +71,10 @@ | |
read_as_raw_records=True, | ||
raw_record_column_name=_RAW_RECORD_COLUMN_NAME, | ||
expected_tfxio_type=raw_tf_record.RawTfRecordTFXIO), | ||
dict( | ||
testcase_name='parquet_payload_format', | ||
payload_format=example_gen_pb2.PayloadFormat.FORMAT_PARQUET, | ||
expected_tfxio_type=parquet_tfxio.ParquetTFXIO), | ||
] | ||
|
||
_RESOLVE_TEST_CASES = [ | ||
|
@@ -181,11 +186,9 @@ def test_make_tfxio(self, payload_format, expected_tfxio_type, | |
_FAKE_FILE_PATTERN, _TELEMETRY_DESCRIPTORS, payload_format, | ||
data_view_uri, _SCHEMA, read_as_raw_records, raw_record_column_name) | ||
self.assertIsInstance(tfxio, expected_tfxio_type) | ||
# We currently only create RecordBasedTFXIO and the check below relies on | ||
# that. | ||
self.assertIsInstance(tfxio, record_based_tfxio.RecordBasedTFXIO) | ||
self.assertEqual(tfxio.telemetry_descriptors, _TELEMETRY_DESCRIPTORS) | ||
self.assertEqual(tfxio.raw_record_column_name, raw_record_column_name) | ||
if isinstance(tfxio, record_based_tfxio.RecordBasedTFXIO): | ||
self.assertEqual(tfxio.raw_record_column_name, raw_record_column_name) | ||
# Since we provide a schema, ArrowSchema() should not raise. | ||
_ = tfxio.ArrowSchema() | ||
|
||
|
@@ -219,11 +222,9 @@ def test_get_tfxio_factory_from_artifact(self, | |
raw_record_column_name) | ||
tfxio = tfxio_factory(_FAKE_FILE_PATTERN) | ||
self.assertIsInstance(tfxio, expected_tfxio_type) | ||
# We currently only create RecordBasedTFXIO and the check below relies on | ||
# that. | ||
self.assertIsInstance(tfxio, record_based_tfxio.RecordBasedTFXIO) | ||
self.assertEqual(tfxio.telemetry_descriptors, _TELEMETRY_DESCRIPTORS) | ||
self.assertEqual(tfxio.raw_record_column_name, raw_record_column_name) | ||
if isinstance(tfxio, record_based_tfxio.RecordBasedTFXIO): | ||
self.assertEqual(tfxio.raw_record_column_name, raw_record_column_name) | ||
# Since we provide a schema, ArrowSchema() should not raise. | ||
_ = tfxio.ArrowSchema() | ||
|
||
|
@@ -306,7 +307,7 @@ def test_get_tf_dataset_factory_from_artifact(self): | |
dataset_factory = tfxio_utils.get_tf_dataset_factory_from_artifact( | ||
[examples], _TELEMETRY_DESCRIPTORS) | ||
self.assertIsInstance(dataset_factory, Callable) | ||
self.assertEqual(tf.data.Dataset, | ||
self.assertEqual('tf.data.Dataset', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this stringify of the signature is a result of adding: |
||
inspect.signature(dataset_factory).return_annotation) | ||
|
||
def test_get_record_batch_factory_from_artifact(self): | ||
|
@@ -317,7 +318,7 @@ def test_get_record_batch_factory_from_artifact(self): | |
record_batch_factory = tfxio_utils.get_record_batch_factory_from_artifact( | ||
[examples], _TELEMETRY_DESCRIPTORS) | ||
self.assertIsInstance(record_batch_factory, Callable) | ||
self.assertEqual(Iterator[pa.RecordBatch], | ||
self.assertEqual('Iterator[pa.RecordBatch]', | ||
inspect.signature(record_batch_factory).return_annotation) | ||
|
||
def test_raise_if_data_view_uri_not_available(self): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
had to add this to allow for proto enums to be used as types in signatures. Not sure if this is something desirable from the tfx side or not @jiyongjung0 @1025KB
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can go back to string in the
make_tfxio
function signature instead of the proto enum type.