Tfx: Cannot use Dict ExecutionParameter at `tfx>=0.28`

Created on 19 Mar 2021  路  3Comments  路  Source: tensorflow/tfx

System information

  • Have I specified the code to reproduce the issue(Yes/No): Yes
  • Environment in which the code is executed: Linux, MacOS, Interactive Notebook
  • TensorFlow version (you are using): 2.4.1
  • TFX Version: tfx>=0.28
  • Python version: 3.7, 3.8

Describe the current behavior

In tfx>=0.28, when using ExecutionParameter with Dict type, I got the error like ValueError: Unexpected type <class 'dict'>.

Describe the expected behavior

If I run the same code in tfx==0.27, it works.

Standalone code to reproduce the issue

Other info / logs

https://github.com/tensorflow/tfx/blob/68637c1faa9c3d7a27e43d87ae85c1639ef1a32a/tfx/types/component_spec.py#L302-L307

As the above comments, it looks like using ExecutionParameter with Dict type should behave normally.

awaiting tensorflower bug

Most helpful comment

It would definitely help, but I can't tell we will as we should also consider the backward compatibility and API consistency. Let me try to bring this issue to the internal discussions.

All 3 comments

Hi Jeonguk. There is a one strict assumption we have for component spec: all exec_properties should be serialized. Serialized exec_properties can be accessed from Executor.Do interface, and you have to manually deserialize your value, unless it is a primitive type. Allowed value types for exec_properties are only int, float, and str.

So being able to use Dict until 0.27 is rather a mistake, but this is not your fault as some components in TFX used to have Dict type exec_properties as well. We realized the mistake last year, and migrated existing Dict type exec_properties to a str type, and then added a serialization/deserialization steps. For example in Trainer there was custom_config exec_properties whose type was originally Dict[str, Any], but later changed to str in a2e040e2e3a8b62ceb2d9d0170188ff263d895c3. We recommend you to do the similar.

Hi Jeonguk. There is a one strict assumption we have for component spec: all exec_properties should be serialized. Serialized exec_properties can be accessed from Executor.Do interface, and you have to manually deserialize your value, unless it is a primitive type. Allowed value types for exec_properties are only int, float, and str.

So being able to use Dict until 0.27 is rather a mistake, but this is not your fault as some components in TFX used to have Dict type exec_properties as well. We realized the mistake last year, and migrated existing Dict type exec_properties to a str type, and then added a serialization/deserialization steps. For example in Trainer there was custom_config exec_properties whose type was originally Dict[str, Any], but later changed to str in a2e040e. We recommend you to do the similar.

@chongkong Thanks. Then, are there any plans to support auto serialization/deserialization steps for exec_properties's value types that consist of python's primitive types and default collection types(e.g.,Dict[str, str], or List[str])? If those value types are type-checked well and automatically serialized/deserialized, I think it can reduce duplicated codes.

It would definitely help, but I can't tell we will as we should also consider the backward compatibility and API consistency. Let me try to bring this issue to the internal discussions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rummens picture rummens  路  6Comments

Malonl picture Malonl  路  6Comments

hanneshapke picture hanneshapke  路  7Comments

rcrowe-google picture rcrowe-google  路  3Comments

Mageswaran1989 picture Mageswaran1989  路  7Comments