@@ -112,38 +112,6 @@ def prepare_image(target_path: Path, function_version: FunctionVersion) -> None:
112
112
)
113
113
114
114
115
- def prepare_version (function_version : FunctionVersion ) -> None :
116
- if not function_version .code .zip_file :
117
- raise NotImplementedError ("Images without zipfile are currently not supported" )
118
- time_before = time .perf_counter ()
119
- target_path = get_path_for_function (function_version )
120
- target_path .mkdir (parents = True , exist_ok = True )
121
- # write code to disk
122
- target_code = get_code_path_for_function (function_version )
123
- with NamedTemporaryFile () as file :
124
- file .write (function_version .code .zip_file )
125
- file .flush ()
126
- unzip (file .name , str (target_code ))
127
- if config .LAMBDA_PREBUILD_IMAGES :
128
- prepare_image (target_path , function_version )
129
- LOG .debug ("Version preparation took %0.2fms" , (time .perf_counter () - time_before ) * 1000 )
130
-
131
-
132
- def cleanup_version (function_version : FunctionVersion ) -> None :
133
- function_path = get_path_for_function (function_version )
134
- try :
135
- shutil .rmtree (function_path )
136
- except OSError as e :
137
- LOG .debug (
138
- "Could not cleanup function %s due to error %s while deleting file %s" ,
139
- function_version .qualified_arn ,
140
- e .strerror ,
141
- e .filename ,
142
- )
143
- if config .LAMBDA_PREBUILD_IMAGES :
144
- CONTAINER_CLIENT .remove_image (get_image_name_for_function (function_version ))
145
-
146
-
147
115
class LambdaRuntimeException (Exception ):
148
116
def __init__ (self , message : str ):
149
117
super ().__init__ (message )
@@ -163,6 +131,38 @@ def __init__(
163
131
self .ip = None
164
132
self .executor_endpoint = self ._build_executor_endpoint (service_endpoint )
165
133
134
+ @staticmethod
135
+ def prepare_version (function_version : FunctionVersion ) -> None :
136
+ if not function_version .code .zip_file :
137
+ raise NotImplementedError ("Images without zipfile are currently not supported" )
138
+ time_before = time .perf_counter ()
139
+ target_path = get_path_for_function (function_version )
140
+ target_path .mkdir (parents = True , exist_ok = True )
141
+ # write code to disk
142
+ target_code = get_code_path_for_function (function_version )
143
+ with NamedTemporaryFile () as file :
144
+ file .write (function_version .code .zip_file )
145
+ file .flush ()
146
+ unzip (file .name , str (target_code ))
147
+ if config .LAMBDA_PREBUILD_IMAGES :
148
+ prepare_image (target_path , function_version )
149
+ LOG .debug ("Version preparation took %0.2fms" , (time .perf_counter () - time_before ) * 1000 )
150
+
151
+ @staticmethod
152
+ def cleanup_version (function_version : FunctionVersion ) -> None :
153
+ function_path = get_path_for_function (function_version )
154
+ try :
155
+ shutil .rmtree (function_path )
156
+ except OSError as e :
157
+ LOG .debug (
158
+ "Could not cleanup function %s due to error %s while deleting file %s" ,
159
+ function_version .qualified_arn ,
160
+ e .strerror ,
161
+ e .filename ,
162
+ )
163
+ if config .LAMBDA_PREBUILD_IMAGES :
164
+ CONTAINER_CLIENT .remove_image (get_image_name_for_function (function_version ))
165
+
166
166
def get_image (self ) -> str :
167
167
if not self .function_version .config .runtime :
168
168
raise NotImplementedError ("Custom images are currently not supported" )
@@ -229,7 +229,10 @@ def get_address(self) -> str:
229
229
raise LambdaRuntimeException (f"IP address of executor '{ self .id } ' unknown" )
230
230
return self .ip
231
231
232
- def get_endpoint_from_executor (self ) -> str :
232
+ def get_executor_endpoint_from_executor (self ) -> str :
233
+ return f"{ get_main_endpoint_from_container ()} :{ self .executor_endpoint .port } "
234
+
235
+ def get_localstack_endpoint_from_executor (self ) -> str :
233
236
return get_main_endpoint_from_container ()
234
237
235
238
def get_network_for_executor (self ) -> str :
0 commit comments