@@ -98,8 +98,6 @@ def _get_patched_obj_metadata(
9898 if not isinstance (metadata , dict ):
9999 logger .warning (f'metadata is not a dict: { metadata } , something wrong was happened when getting response when get bucket and object information.' )
100100 return metadata
101- if not task_params and not custom_labels :
102- return metadata
103101 # Maximum size of metadata for each object is 8 KiB.
104102 # [Link]: https://cloud.google.com/storage/quotas#objects
105103 normalized_task_params_labels = GCSObjectMetadataClient ._normalize_labels (task_params )
@@ -117,18 +115,17 @@ def _get_patched_obj_metadata(
117115
118116 @staticmethod
119117 def _get_serialized_string (required_task_outputs : FlattenableItems [RequiredTaskOutput ]) -> FlattenableItems [str ]:
120- def _iterable_flatten (nested_list : Iterable ) -> Iterable [str ]:
121- for item in nested_list :
122- if isinstance (item , Iterable ):
123- yield from _iterable_flatten (item )
124- else :
125- yield item
126-
127- if isinstance (required_task_outputs , dict ):
118+ if isinstance (required_task_outputs , RequiredTaskOutput ):
119+ return required_task_outputs .serialize ()
120+ elif isinstance (required_task_outputs , dict ):
128121 return {k : GCSObjectMetadataClient ._get_serialized_string (v ) for k , v in required_task_outputs .items ()}
129- if isinstance (required_task_outputs , Iterable ):
130- return list (_iterable_flatten ([GCSObjectMetadataClient ._get_serialized_string (ro ) for ro in required_task_outputs ]))
131- return [required_task_outputs .serialize ()]
122+ elif isinstance (required_task_outputs , Iterable ):
123+ return [GCSObjectMetadataClient ._get_serialized_string (ro ) for ro in required_task_outputs ]
124+ else :
125+ raise TypeError (
126+ f'Unsupported type for required_task_outputs: { type (required_task_outputs )} . '
127+ 'It should be RequiredTaskOutput, dict, or iterable of RequiredTaskOutput.'
128+ )
132129
133130 @staticmethod
134131 def _merge_custom_labels_and_task_params_labels (
0 commit comments