Skip to content

Commit

Permalink
Add a helper function to create an empty placeholder context and upda…
Browse files Browse the repository at this point in the history
…te tests to use the helper.

PiperOrigin-RevId: 650300708
  • Loading branch information
tfx-copybara committed Jul 9, 2024
1 parent fffb9d7 commit e1fd430
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
7 changes: 7 additions & 0 deletions tfx/dsl/compiler/placeholder_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ def resolve_placeholder_expression(
return result


def empty_placeholder_context() -> ResolutionContext:
"""Returns an empty placeholder context."""
return ResolutionContext(
exec_info=data_types.ExecutionInfo(),
)


class _Operation(enum.Enum):
"""Alias for Operation enum types in placeholder.proto."""

Expand Down
4 changes: 2 additions & 2 deletions tfx/dsl/compiler/placeholder_utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1689,8 +1689,8 @@ def testMakeProtoOpResolvesProto(self):
placeholder_pb2.PlaceholderExpression(),
)
resolved_proto = placeholder_utils.resolve_placeholder_expression(
placeholder_expression, placeholder_utils.ResolutionContext(
exec_info=data_types.ExecutionInfo()))
placeholder_expression, placeholder_utils.empty_placeholder_context()
)
self.assertProtoEquals(
"""
splits: "train"
Expand Down
5 changes: 1 addition & 4 deletions tfx/dsl/placeholder/placeholder_test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

from tfx.dsl.compiler import placeholder_utils
from tfx.dsl.placeholder import placeholder_base
from tfx.orchestration.portable import data_types


def resolve(
Expand All @@ -39,9 +38,7 @@ def resolve(
return placeholder_utils.resolve_placeholder_expression(
placeholder.encode(),
resolution_context
or placeholder_utils.ResolutionContext(
exec_info=data_types.ExecutionInfo()
),
or placeholder_utils.empty_placeholder_context(),
)


Expand Down

0 comments on commit e1fd430

Please sign in to comment.