[go: nahoru, domu]

Skip to content

Commit

Permalink
Removing long deprecated APIs:
Browse files Browse the repository at this point in the history
 - uniques (replaced with vocabulary)
 - string_to_int (replaced with compute_and_apply_vocabulary)
 - apply_vocab (replaced with apply_vocabulary)
 - expected_asset_file_contents (replaced with expected_vocab_file_contents)
 - tft.apply_function (it was an identify function)

PiperOrigin-RevId: 364364285
  • Loading branch information
zoyahav authored and tf-transform-team committed Mar 22, 2021
1 parent 1d02be4 commit fb18a3a
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 130 deletions.
4 changes: 4 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
the 0.25 release.
[Canned TFXIO implementations](https://www.tensorflow.org/tfx/tfx_bsl/api_docs/python/tfx_bsl/public/tfxio)
should be used to read and decode data instead.
* Previously deprecated APIs were removed: `tft.uniques` (replaced by
`tft.vocabulary`), `tft.string_to_int` (replaced by
`tft.compute_and_apply_vocabulary`), `tft.apply_vocab` (replaced by
`tft.apply_vocabulary`), and `tft.apply_function` (identity function).

## Breaking Changes

Expand Down
2 changes: 1 addition & 1 deletion tensorflow_transform/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from tensorflow_transform import coders
from tensorflow_transform.analyzers import *
from tensorflow_transform.annotators import *
from tensorflow_transform.api import apply_function
# Deprecated tft.apply_function placeholder.
from tensorflow_transform.inspect_preprocessing_fn import *
from tensorflow_transform.mappers import *
from tensorflow_transform.output_wrapper import TFTransformOutput
Expand Down
23 changes: 0 additions & 23 deletions tensorflow_transform/analyzers.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
'tukey_location',
'tukey_scale',
'tukey_h_params',
'uniques',
'var',
'vocabulary',
]
Expand Down Expand Up @@ -2018,28 +2017,6 @@ def calculate_recommended_min_diff_from_avg(dataset_size: int) -> int:
(max_value - min_value) + min_value)))


@deprecation.deprecated(None, 'Use `tft.vocabulary()` instead.')
@common.log_api_use(common.ANALYZER_COLLECTION)
def uniques(x,
top_k=None,
frequency_threshold=None,
vocab_filename=None,
store_frequency=False,
weights=None,
labels=None,
name=None):
r"""See `tft.vocabulary`."""
return vocabulary(
x=x,
top_k=top_k,
frequency_threshold=frequency_threshold,
vocab_filename=vocab_filename,
store_frequency=store_frequency,
weights=weights,
labels=labels,
name=name)


# Code related to this class is performance sensitive, so (micro-)benchmarks
# should be run when it is updated.
class QuantilesCombiner(analyzer_nodes.Combiner):
Expand Down
41 changes: 0 additions & 41 deletions tensorflow_transform/api.py

This file was deleted.

2 changes: 1 addition & 1 deletion tensorflow_transform/beam/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"""An implementation of tf.Transform using Beam.
The beam implementation takes a user defined preprocessing function (see
../api.py for how to defined a preprocessing function) and implements it as a
examples for how to define a preprocessing function) and implements it as a
Beam PTransform.
The AnalyzeDataset takes the user's preprocessing function and converts into
Expand Down
19 changes: 2 additions & 17 deletions tensorflow_transform/beam/tft_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ def assertAnalyzeAndTransformResults(self,
expected_data=None,
expected_metadata=None,
expected_vocab_file_contents=None,
expected_asset_file_contents=None,
test_data=None,
desired_batch_size=None,
beam_pipeline=None,
Expand Down Expand Up @@ -266,8 +265,6 @@ def assertAnalyzeAndTransformResults(self,
to their expected content as a list of text lines or a list of tuples
of frequency and text. Values should be the expected result of calling
f.readlines() on the given asset files.
expected_asset_file_contents: deprecated. Use
expected_vocab_file_contents.
test_data: (optional) If this is provided then instead of calling
AnalyzeAndTransformDataset with input_data, this function will call
AnalyzeDataset with input_data and TransformDataset with test_data.
Expand All @@ -287,21 +284,9 @@ def assertAnalyzeAndTransformResults(self,
AssertionError: if the expected data does not match the results of
transforming input_data according to preprocessing_fn, or
(if provided) if the expected metadata does not match.
ValueError: if expected_vocab_file_contents and
expected_asset_file_contents are both set.
"""
if (expected_vocab_file_contents is not None and
expected_asset_file_contents is not None):
raise ValueError('only one of expected_asset_file_contents and '
'expected_asset_file_contents should be set')
elif expected_asset_file_contents is not None:
tf.compat.v1.logging.warn(
'expected_asset_file_contents is deprecated, use '
'expected_vocab_file_contents')

expected_vocab_file_contents = (
expected_vocab_file_contents or expected_asset_file_contents or {})
del expected_asset_file_contents

expected_vocab_file_contents = expected_vocab_file_contents or {}

# Note: we don't separately test AnalyzeDataset and TransformDataset as
# AnalyzeAndTransformDataset currently simply composes these two
Expand Down
47 changes: 0 additions & 47 deletions tensorflow_transform/mappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1048,33 +1048,6 @@ def compute_and_apply_vocabulary(
file_format=file_format)


@deprecation.deprecated(None,
'Use `tft.compute_and_apply_vocabulary()` instead.')
@common.log_api_use(common.MAPPER_COLLECTION)
def string_to_int(x,
default_value=-1,
top_k=None,
frequency_threshold=None,
num_oov_buckets=0,
vocab_filename=None,
weights=None,
labels=None,
file_format=analyzers.DEFAULT_VOCABULARY_FILE_FORMAT,
name=None):
r"""See `tft.compute_and_apply_vocabulary`."""
return compute_and_apply_vocabulary(
x=x,
default_value=default_value,
top_k=top_k,
frequency_threshold=frequency_threshold,
num_oov_buckets=num_oov_buckets,
vocab_filename=vocab_filename,
weights=weights,
labels=labels,
file_format=file_format,
name=name)


@common.log_api_use(common.MAPPER_COLLECTION)
def apply_vocabulary(
x: common_types.ConsistentTensorType,
Expand Down Expand Up @@ -1185,26 +1158,6 @@ def _construct_table(asset_filepath):
return result


@deprecation.deprecated(None, 'Use `tft.apply_vocabulary()` instead.')
@common.log_api_use(common.MAPPER_COLLECTION)
def apply_vocab(x,
deferred_vocab_filename_tensor,
default_value=-1,
num_oov_buckets=0,
lookup_fn=None,
file_format=analyzers.DEFAULT_VOCABULARY_FILE_FORMAT,
name=None):
r"""See `tft.apply_vocabulary`."""
return apply_vocabulary(
x=x,
deferred_vocab_filename_tensor=deferred_vocab_filename_tensor,
default_value=default_value,
num_oov_buckets=num_oov_buckets,
lookup_fn=lookup_fn,
file_format=file_format,
name=name)


@common.log_api_use(common.MAPPER_COLLECTION)
def get_num_buckets_for_transformed_feature(
transformed_feature: common_types.TensorType) -> tf.Tensor:
Expand Down

0 comments on commit fb18a3a

Please sign in to comment.