You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SDK - Controlling which modules are captured with Lightweight components
All func_to_* functions now accept the modules_to_capture parameter: List of module names that will be captured (instead of just referencing) during the dependency scan. By default the func.__module__ is captured.
# Hack to force cloudpickle to capture the whole function instead of just referencing the code file. See https://github.com/cloudpipe/cloudpickle/blob/74d69d759185edaeeac7bdcb7015cfc0c652f204/cloudpickle/cloudpickle.py#L490
57
+
old_modules= {}
53
58
try: # Try is needed to restore the state if something goes wrong
'''Takes a self-contained python function and converts it to component
78
85
79
86
Args:
80
87
func: Required. The function to be converted
81
88
base_image: Optional. Docker image to be used as a base image for the python component. Must have python 3.5+ installed. Default is tensorflow/tensorflow:1.11.0-py3
82
89
Note: The image can also be specified by decorating the function with the @python_component decorator. If different base images are explicitly specified in both places, an error is raised.
83
90
extra_code: Optional. Python source code that gets placed before the function code. Can be used as workaround to define types used in function signature.
91
+
modules_to_capture: Optional. List of module names that will be captured (instead of just referencing) during the dependency scan. By default the func.__module__ is captured.
base_image: Optional. Specify a custom Docker container image to use in the component. For lightweight components, the image needs to have python 3.5+. Default is tensorflow/tensorflow:1.11.0-py3
255
263
Note: The image can also be specified by decorating the function with the @python_component decorator. If different base images are explicitly specified in both places, an error is raised.
256
264
extra_code: Optional. Extra code to add before the function code. Can be used as workaround to define types used in function signature.
265
+
modules_to_capture: Optional. List of module names that will be captured (instead of just referencing) during the dependency scan. By default the func.__module__ is captured.
base_image: Optional. Specify a custom Docker container image to use in the component. For lightweight components, the image needs to have python 3.5+. Default is tensorflow/tensorflow:1.11.0-py3
282
291
Note: The image can also be specified by decorating the function with the @python_component decorator. If different base images are explicitly specified in both places, an error is raised.
283
292
extra_code: Optional. Extra code to add before the function code. Can be used as workaround to define types used in function signature.
293
+
modules_to_capture: Optional. List of module names that will be captured (instead of just referencing) during the dependency scan. By default the func.__module__ is captured.
Note: The image can also be specified by decorating the function with the @python_component decorator. If different base images are explicitly specified in both places, an error is raised.
308
318
output_component_file: Optional. Write a component definition to a local file. Can be used for sharing.
309
319
extra_code: Optional. Extra code to add before the function code. Can be used as workaround to define types used in function signature.
320
+
modules_to_capture: Optional. List of module names that will be captured (instead of just referencing) during the dependency scan. By default the func.__module__ is captured.
310
321
311
322
Returns:
312
323
A factory function with a strongly-typed signature taken from the python function.
313
324
Once called with the required arguments, the factory constructs a pipeline task instance (ContainerOp) that can run the original function in a container.
0 commit comments