1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15+ from __future__ import annotations
16+
1517import atexit
18+ import logging
1619import os
1720from typing import Optional
1821
2730from .code_execution_utils import CodeExecutionInput
2831from .code_execution_utils import CodeExecutionResult
2932
33+ logger = logging .getLogger ('google_adk.' + __name__ )
3034DEFAULT_IMAGE_TAG = 'adk-code-executor:latest'
3135
3236
@@ -151,13 +155,13 @@ def _build_docker_image(self):
151155 if not os .path .exists (self .docker_path ):
152156 raise FileNotFoundError (f'Invalid Docker path: { self .docker_path } ' )
153157
154- print ('Building Docker image...' )
158+ logger . info ('Building Docker image...' )
155159 self ._client .images .build (
156160 path = self .docker_path ,
157161 tag = self .image ,
158162 rm = True ,
159163 )
160- print ( f 'Docker image: { self . image } built.' )
164+ logger . info ( 'Docker image: %s built.' , self . image )
161165
162166 def _verify_python_installation (self ):
163167 """Verifies the container has python3 installed."""
@@ -173,13 +177,13 @@ def __init_container(self):
173177 if self .docker_path :
174178 self ._build_docker_image ()
175179
176- print ('Starting container for ContainerCodeExecutor...' )
180+ logger . info ('Starting container for ContainerCodeExecutor...' )
177181 self ._container = self ._client .containers .run (
178182 image = self .image ,
179183 detach = True ,
180184 tty = True ,
181185 )
182- print ( f 'Container { self ._container .id } started.' )
186+ logger . info ( 'Container %s started.' , self ._container .id )
183187
184188 # Verify the container is able to run python3.
185189 self ._verify_python_installation ()
@@ -189,7 +193,7 @@ def __cleanup_container(self):
189193 if not self ._container :
190194 return
191195
192- print ('[Cleanup] Stopping the container...' )
196+ logger . info ('[Cleanup] Stopping the container...' )
193197 self ._container .stop ()
194198 self ._container .remove ()
195- print ( f 'Container { self . _container . id } stopped and removed.' )
199+ logger . info ( 'Container %s stopped and removed.' , self . _container . id )
0 commit comments