Skip to content

Commit 009808f

Browse files
jiyongjungtfx-copybara
jiyongjung
authored andcommitted
Skips a flakky airflow test on macos.
Recent versions of Tensorflow and Airflow makes test fails with segmentation faults. Airflow doesn't support macos as an execution environment.[1] [1] apache/airflow#11965 (comment) PiperOrigin-RevId: 364952307
1 parent 4087f18 commit 009808f

File tree

12 files changed

+52
-64
lines changed

12 files changed

+52
-64
lines changed

tfx/dependencies.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,7 @@ def make_extra_packages_examples():
164164
'tensorflow-ranking>=0.3.3,<0.4',
165165
'struct2tensor>=0.28,<0.29',
166166
# Required for tfx/examples/penguin/experimental
167-
# LINT.IfChange
168-
'scikit-learn>=0.23,<0.24',
169-
# LINT.ThenChange(
170-
# examples/penguin/experimental/penguin_pipeline_sklearn_gcp.py)
167+
'scikit-learn>=0.24,<0.25',
171168
]
172169

173170

tfx/dsl/component/experimental/executor_specs.py

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,20 @@ class MyTrainerSpec(types.ComponentSpec):
7474
command: Container entrypoint command-line. Not executed within a shell.
7575
The command-line can use placeholder objects that will be replaced at
7676
the compilation time. Note: Jinja templates are not supported.
77-
args: Container entrypoint command-args.
7877
"""
7978

79+
# The "command" parameter holds the name of the program and its arguments.
80+
# The "command" parameter is required to enable instrumentation.
81+
# The command-line is often split into command+args, but here "args" would be
82+
# redundant since all items can just be added to "command".
83+
8084
def __init__(
8185
self,
8286
image: Text,
83-
command: Optional[List[placeholders.CommandlineArgumentType]] = None,
84-
args: Optional[List[placeholders.CommandlineArgumentType]] = None,
87+
command: List[placeholders.CommandlineArgumentType],
8588
):
8689
self.image = image
87-
self.command = command or []
88-
self.args = args or []
90+
self.command = command
8991
super(TemplatedExecutorContainerSpec, self).__init__()
9092

9193
def __eq__(self, other) -> bool:
@@ -96,27 +98,27 @@ def __ne__(self, other) -> bool:
9698
return not self.__eq__(other)
9799

98100
def _recursively_encode(
99-
self, ph: placeholders.CommandlineArgumentType
101+
self, command: placeholders.CommandlineArgumentType
100102
) -> Union[str, placeholder.Placeholder]:
101-
if isinstance(ph, str):
102-
return ph
103-
elif isinstance(ph, placeholders.InputValuePlaceholder):
104-
return placeholder.input(ph.input_name)[0]
105-
elif isinstance(ph, placeholders.InputUriPlaceholder):
106-
return placeholder.input(ph.input_name)[0].uri
107-
elif isinstance(ph, placeholders.OutputUriPlaceholder):
108-
return placeholder.output(ph.output_name)[0].uri
109-
elif isinstance(ph, placeholders.ConcatPlaceholder):
103+
if isinstance(command, str):
104+
return command
105+
elif isinstance(command, placeholders.InputValuePlaceholder):
106+
return placeholder.input(command.input_name)[0]
107+
elif isinstance(command, placeholders.InputUriPlaceholder):
108+
return placeholder.input(command.input_name)[0].uri
109+
elif isinstance(command, placeholders.OutputUriPlaceholder):
110+
return placeholder.output(command.output_name)[0].uri
111+
elif isinstance(command, placeholders.ConcatPlaceholder):
110112
# operator.add wil use the overloaded __add__ operator for Placeholder
111113
# instances.
112114
return functools.reduce(
113115
operator.add,
114-
[self._recursively_encode(item) for item in ph.items])
116+
[self._recursively_encode(item) for item in command.items])
115117
else:
116118
raise TypeError(
117-
('Unsupported type of placeholder arguments: "{}".'
119+
('Unsupported type of command-line arguments: "{}".'
118120
' Supported types are {}.')
119-
.format(type(ph), str(placeholders.CommandlineArgumentType)))
121+
.format(type(command), str(placeholders.CommandlineArgumentType)))
120122

121123
def encode(
122124
self,
@@ -142,14 +144,4 @@ def encode(
142144
cmd.CopyFrom(expression)
143145
else:
144146
cmd.CopyFrom(self._recursively_encode(command).encode())
145-
146-
for arg in self.args:
147-
cmd = result.args.add()
148-
str_or_placeholder = self._recursively_encode(arg)
149-
if isinstance(str_or_placeholder, str):
150-
expression = placeholder_pb2.PlaceholderExpression()
151-
expression.value.string_value = str_or_placeholder
152-
cmd.CopyFrom(expression)
153-
else:
154-
cmd.CopyFrom(self._recursively_encode(arg).encode())
155147
return result

tfx/dsl/component/experimental/executor_specs_test.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,6 @@ def testEncodeTemplatedExecutorContainerSpec_withConcatAllText(self):
166166
image='image',
167167
command=[
168168
self._text_concat_placeholder
169-
],
170-
args=[
171-
self._text_concat_placeholder
172169
])
173170
encode_result = specs.encode()
174171
self.assertProtoEquals("""
@@ -177,11 +174,6 @@ def testEncodeTemplatedExecutorContainerSpec_withConcatAllText(self):
177174
value {
178175
string_value: "texttext1text2"
179176
}
180-
}
181-
args {
182-
value {
183-
string_value: "texttext1text2"
184-
}
185177
}""", encode_result)
186178

187179

tfx/examples/chicago_taxi_pipeline/taxi_pipeline_simple_airflow_e2e_test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
"""End to end test for tfx.orchestration.airflow."""
1515

1616
import os
17+
import platform
1718
import subprocess
1819
import time
1920
from typing import Sequence, Set, Text
21+
import unittest
2022

2123
import absl
2224
import tensorflow as tf
@@ -54,6 +56,11 @@ def __exit__(self, exception_type, exception_value, traceback): # pylint: disab
5456
_PENDING_TASK_STATES = set(['queued', 'scheduled', 'running', 'none'])
5557

5658

59+
@unittest.skipIf(
60+
platform.system() == 'Darwin',
61+
'Airflow is not compatible with TF in some environments on macos and '
62+
'Airflow Executor is not supported on macos. See b/178137745.'
63+
)
5764
class AirflowEndToEndTest(test_case_utils.TfxTest):
5865
"""An end to end test using fully orchestrated Airflow."""
5966

tfx/examples/penguin/experimental/Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,8 @@
1313
# limitations under the License.
1414

1515
ARG TFX_VERSION
16-
FROM tensorflow/tfx:$TFX_VERSION
17-
RUN pip install -U tfx[examples]
16+
FROM gcr.io/tfx-oss-public/tfx:$TFX_VERSION
17+
18+
RUN pip install \
19+
scikit-learn==0.20.4 \
20+
numpy==1.16.5

tfx/examples/penguin/experimental/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ image and upload it to Google Container Registry (GCR).
4545
<pre class="devsite-terminal devsite-click-to-copy">
4646
gcloud auth configure-docker
4747
docker build \
48-
--tag gcr.io/[PROJECT-ID]/tfx-example-sklearn
48+
--tag tfx-example-sklearn \
4949
--build-arg TFX_VERSION=$(python -c 'import tfx; print(tfx.__version__)') \
5050
.
51+
docker tag tfx-example-sklearn gcr.io/[PROJECT-ID]/tfx-example-sklearn
5152
docker push gcr.io/[PROJECT-ID]/tfx-example-sklearn
5253
</pre>
5354

tfx/examples/penguin/experimental/penguin_pipeline_sklearn_gcp.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,9 @@
8686
# Note that serving currently only supports a single region:
8787
# https://cloud.google.com/ml-engine/reference/rest/v1/projects.models#Model
8888
'regions': [_gcp_region],
89-
# TODO(b/176256164): Update to runtime version 2.4 once that is available
90-
# to align with the version of TF supported by TFX.
91-
# LINT.IfChange
92-
'runtime_version': '2.3',
93-
# LINT.ThenChange(../../../dependencies.py)
89+
# TODO(b/157646655): Update the version once sklearn support is added back
90+
# to CAIP in the next runtime release.
91+
'runtime_version': '1.15',
9492
}
9593

9694
# This example assumes that Penguin data is stored in ~/penguin/data and the
@@ -160,6 +158,7 @@ def _create_pipeline(pipeline_name: Text, pipeline_root: Text, data_root: Text,
160158
# Uses user-provided Python function that trains a model using TF-Learn.
161159
# Num_steps is not provided during evaluation because the scikit-learn model
162160
# loads and evaluates the entire test set at once.
161+
# TODO(b/159470716): Make schema optional in Trainer.
163162
trainer = Trainer(
164163
module_file=trainer_module_file,
165164
custom_executor_spec=executor_spec.ExecutorClassSpec(

tfx/examples/penguin/experimental/penguin_pipeline_sklearn_local.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def _create_pipeline(pipeline_name: Text, pipeline_root: Text, data_root: Text,
106106
# Uses user-provided Python function that trains a model using TF-Learn.
107107
# Num_steps is not provided during evaluation because the scikit-learn model
108108
# loads and evaluates the entire test set at once.
109+
# TODO(b/159470716): Make schema optional in Trainer.
109110
trainer = Trainer(
110111
module_file=trainer_module_file,
111112
custom_executor_spec=executor_spec.ExecutorClassSpec(GenericExecutor),

tfx/extensions/google_cloud_ai_platform/runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ def deploy_model_for_aip_prediction(api: discovery.Resource,
377377
if e.resp.status == 409:
378378
logging.warn('Model version %s already exists', model_version)
379379
else:
380-
raise RuntimeError('Creating model version to AI Platform failed: {}'
380+
raise RuntimeError('Creating model verseion to AI Platform failed: {}'
381381
.format(e))
382382

383383
if set_default_version:

tfx/orchestration/kubeflow/container_entrypoint.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,6 @@ def main():
310310
parser.add_argument('--serialized_component', type=str, required=True)
311311
parser.add_argument('--component_config', type=str, required=True)
312312

313-
# TODO(b/182220464): Uses following flags and change to required.
314-
parser.add_argument('--tfx_ir', type=str, required=False)
315-
parser.add_argument('--node_id', type=str, required=False)
316-
317313
args = parser.parse_args()
318314

319315
component = json_utils.loads(args.serialized_component)

tfx/tools/cli/handler/base_handler.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,11 @@ def _subprocess_call(self,
191191
def _format_table(self, header: Collection[Any],
192192
data: Collection[Collection[Any]]):
193193

194-
def _format_as_strings(items):
195-
return [f' {item} ' for item in items]
194+
def _force_strings(items):
195+
return [str(item) for item in items]
196196

197-
header = _format_as_strings(header)
198-
data = [_format_as_strings(row) for row in data]
197+
header = _force_strings(header)
198+
data = [_force_strings(row) for row in data]
199199

200200
max_widths = [len(s) for s in header]
201201
for row in data:

tfx/tools/cli/handler/base_handler_test.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,13 @@ def testFormatTable(self):
207207
handler = FakeHandler(flags_dict)
208208
self.assertEqual(
209209
textwrap.dedent("""\
210-
+=====+=====+=======+
211-
| abc | d | False |
212-
+=====+=====+=======+
213-
| 1 | 234 | None |
214-
+-----+-----+-------+
215-
| xxx | | [] |
216-
+=====+=====+=======+
210+
+===+===+=====+
211+
|abc|d |False|
212+
+===+===+=====+
213+
|1 |234|None |
214+
+---+---+-----+
215+
|xxx| |[] |
216+
+===+===+=====+
217217
"""),
218218
handler._format_table(('abc', 'd', False),
219219
[[1, '234', None], ['xxx', '', []]]))

0 commit comments

Comments
 (0)