tft_beam.Context
Stay organized with collections
Save and categorize content based on your preferences.
Context manager for tensorflow-transform.
tft_beam.Context(
temp_dir: Optional[str] = None,
desired_batch_size: Optional[int] = None,
passthrough_keys: Optional[Iterable[str]] = None,
use_deep_copy_optimization: Optional[bool] = None,
force_tf_compat_v1: Optional[bool] = None,
save_options: Optional[tf.saved_model.SaveOptions] = None
)
All the attributes in this context are kept on a thread local state.
Note that the temp dir should be accessible to worker jobs, e.g. if running
with the Cloud Dataflow runner, the temp dir should be on GCS and should have
permissions that allow both launcher and workers to access it.
Attributes |
temp_dir
|
(Optional) The temporary directory used within in this block.
|
desired_batch_size
|
(Optional) A batch size to batch elements by. If not
provided, a batch size will be computed automatically.
|
passthrough_keys
|
(Optional) A set of strings that are keys to
instances that should pass through the pipeline and be hidden from
the preprocessing_fn. This should only be used in cases where additional
information should be attached to instances in the pipeline which should
not be part of the transformation graph, instance keys is one such
example.
|
use_deep_copy_optimization
|
(Optional) If True, makes deep copies of
PCollections that are used in multiple TFT phases.
|
force_tf_compat_v1
|
(Optional) If True, TFT's public APIs
(e.g. AnalyzeDataset) will use Tensorflow in compat.v1 mode irrespective
of installed version of Tensorflow. Defaults to False .
|
save_options
|
(Optional) If set, the tf.saved_model.SaveOptions to save
the transform_fn with. Only applies for TF2.
|
Methods
create_base_temp_dir
View source
@classmethod
create_base_temp_dir() -> str
Generate a temporary location.
get_desired_batch_size
View source
@classmethod
get_desired_batch_size() -> Optional[int]
Retrieves a user set fixed batch size, None if not set.
get_passthrough_keys
View source
@classmethod
get_passthrough_keys() -> Iterable[str]
Retrieves a user set passthrough_keys, None if not set.
get_save_options
View source
@classmethod
get_save_options() -> Optional[tf.saved_model.SaveOptions]
Retrieves a user set save_options, None if not set.
get_use_deep_copy_optimization
View source
@classmethod
get_use_deep_copy_optimization() -> bool
Retrieves a user set use_deep_copy_optimization, None if not set.
get_use_tf_compat_v1
View source
@classmethod
get_use_tf_compat_v1() -> bool
Computes use_tf_compat_v1 from TF environment and force_tf_compat_v1.
__enter__
View source
__enter__()
__exit__
View source
__exit__(
*exn_info
)
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-11-01 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-11-01 UTC."],[],[],null,["# tft_beam.Context\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/transform/blob/v1.16.0/tensorflow_transform/beam/context.py#L25-L192) |\n\nContext manager for tensorflow-transform. \n\n tft_beam.Context(\n temp_dir: Optional[str] = None,\n desired_batch_size: Optional[int] = None,\n passthrough_keys: Optional[Iterable[str]] = None,\n use_deep_copy_optimization: Optional[bool] = None,\n force_tf_compat_v1: Optional[bool] = None,\n save_options: Optional[tf.saved_model.SaveOptions] = None\n )\n\nAll the attributes in this context are kept on a thread local state.\nNote that the temp dir should be accessible to worker jobs, e.g. if running\nwith the Cloud Dataflow runner, the temp dir should be on GCS and should have\npermissions that allow both launcher and workers to access it.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ---------- ||\n|------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `temp_dir` | (Optional) The temporary directory used within in this block. |\n| `desired_batch_size` | (Optional) A batch size to batch elements by. If not provided, a batch size will be computed automatically. |\n| `passthrough_keys` | (Optional) A set of strings that are keys to instances that should pass through the pipeline and be hidden from the preprocessing_fn. This should only be used in cases where additional information should be attached to instances in the pipeline which should not be part of the transformation graph, instance keys is one such example. |\n| `use_deep_copy_optimization` | (Optional) If True, makes deep copies of PCollections that are used in multiple TFT phases. |\n| `force_tf_compat_v1` | (Optional) If True, TFT's public APIs (e.g. AnalyzeDataset) will use Tensorflow in compat.v1 mode irrespective of installed version of Tensorflow. Defaults to `False`. |\n| `save_options` | (Optional) If set, the tf.saved_model.SaveOptions to save the transform_fn with. Only applies for TF2. |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `create_base_temp_dir`\n\n[View source](https://github.com/tensorflow/transform/blob/v1.16.0/tensorflow_transform/beam/context.py#L130-L143) \n\n @classmethod\n create_base_temp_dir() -\u003e str\n\nGenerate a temporary location.\n\n### `get_desired_batch_size`\n\n[View source](https://github.com/tensorflow/transform/blob/v1.16.0/tensorflow_transform/beam/context.py#L145-L153) \n\n @classmethod\n get_desired_batch_size() -\u003e Optional[int]\n\nRetrieves a user set fixed batch size, None if not set.\n\n### `get_passthrough_keys`\n\n[View source](https://github.com/tensorflow/transform/blob/v1.16.0/tensorflow_transform/beam/context.py#L155-L161) \n\n @classmethod\n get_passthrough_keys() -\u003e Iterable[str]\n\nRetrieves a user set passthrough_keys, None if not set.\n\n### `get_save_options`\n\n[View source](https://github.com/tensorflow/transform/blob/v1.16.0/tensorflow_transform/beam/context.py#L185-L192) \n\n @classmethod\n get_save_options() -\u003e Optional[tf.saved_model.SaveOptions]\n\nRetrieves a user set save_options, None if not set.\n\n### `get_use_deep_copy_optimization`\n\n[View source](https://github.com/tensorflow/transform/blob/v1.16.0/tensorflow_transform/beam/context.py#L163-L169) \n\n @classmethod\n get_use_deep_copy_optimization() -\u003e bool\n\nRetrieves a user set use_deep_copy_optimization, None if not set.\n\n### `get_use_tf_compat_v1`\n\n[View source](https://github.com/tensorflow/transform/blob/v1.16.0/tensorflow_transform/beam/context.py#L179-L183) \n\n @classmethod\n get_use_tf_compat_v1() -\u003e bool\n\nComputes use_tf_compat_v1 from TF environment and force_tf_compat_v1.\n\n### `__enter__`\n\n[View source](https://github.com/tensorflow/transform/blob/v1.16.0/tensorflow_transform/beam/context.py#L101-L119) \n\n __enter__()\n\n### `__exit__`\n\n[View source](https://github.com/tensorflow/transform/blob/v1.16.0/tensorflow_transform/beam/context.py#L121-L122) \n\n __exit__(\n *exn_info\n )"]]