Skip to content

Commit 29f0b0c

Browse files
committed
Add a helper function to create an empty placeholder context and update tests to use the helper.
PiperOrigin-RevId: 650706765
1 parent fffb9d7 commit 29f0b0c

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

tfx/dsl/compiler/placeholder_utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ def resolve_placeholder_expression(
129129
return result
130130

131131

132+
def empty_placeholder_context() -> ResolutionContext:
133+
"""Returns an empty placeholder context."""
134+
return ResolutionContext(
135+
exec_info=data_types.ExecutionInfo(),
136+
)
137+
138+
132139
class _Operation(enum.Enum):
133140
"""Alias for Operation enum types in placeholder.proto."""
134141

tfx/dsl/compiler/placeholder_utils_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,8 +1689,8 @@ def testMakeProtoOpResolvesProto(self):
16891689
placeholder_pb2.PlaceholderExpression(),
16901690
)
16911691
resolved_proto = placeholder_utils.resolve_placeholder_expression(
1692-
placeholder_expression, placeholder_utils.ResolutionContext(
1693-
exec_info=data_types.ExecutionInfo()))
1692+
placeholder_expression, placeholder_utils.empty_placeholder_context()
1693+
)
16941694
self.assertProtoEquals(
16951695
"""
16961696
splits: "train"

tfx/dsl/placeholder/placeholder_test_util.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
from tfx.dsl.compiler import placeholder_utils
1919
from tfx.dsl.placeholder import placeholder_base
20-
from tfx.orchestration.portable import data_types
2120

2221

2322
def resolve(
@@ -39,9 +38,7 @@ def resolve(
3938
return placeholder_utils.resolve_placeholder_expression(
4039
placeholder.encode(),
4140
resolution_context
42-
or placeholder_utils.ResolutionContext(
43-
exec_info=data_types.ExecutionInfo()
44-
),
41+
or placeholder_utils.empty_placeholder_context(),
4542
)
4643

4744

0 commit comments

Comments
 (0)