8000 chore: replace print with logger.info · devevignesh/adk-python@078ac84 · GitHub
[go: up one dir, main page]

Skip to content

Commit 078ac84

Browse files
seanzhougooglecopybara-github
authored andcommitted
chore: replace print with logger.info
PiperOrigin-RevId: 767732597
1 parent 4b1c218 commit 078ac84

File tree

5 files changed

+32
-14
lines changed

5 files changed

+32
-14
lines changed

src/google/adk/code_executors/container_code_executor.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
from __future__ import annotations
16+
1517
import atexit
18+
import logging
1619
import os
1720
from typing import Optional
1821

@@ -27,6 +30,7 @@
2730
from .code_execution_utils import CodeExecutionInput
2831
from .code_execution_utils import CodeExecutionResult
2932

33+
logger = logging.getLogger('google_adk.' + __name__)
3034
DEFAULT_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)

src/google/adk/code_executors/vertex_ai_code_executor.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import datetime
15+
from __future__ import annotations
16+
17+
import logging
1618
import mimetypes
1719
import os
1820
from typing import Any
@@ -27,6 +29,8 @@
2729
from .code_execution_utils import CodeExecutionResult
2830
from .code_execution_utils import File
2931

32+
logger = logging.getLogger('google_adk.' + __name__)
33+
3034
_SUPPORTED_IMAGE_TYPES = ['png', 'jpg', 'jpeg']
3135
_SUPPORTED_DATA_FILE_TYPES = ['csv']
3236

@@ -89,7 +93,9 @@ def _get_code_interpreter_extension(resource_name: str = None):
8993
if resource_name:
9094
new_code_interpreter = Extension(resource_name)
9195
else:
92-
print('No CODE_INTERPRETER_ID found in the environment. Create a new one.')
96+
logger.info(
97+
'No CODE_INTERPRETER_ID found in the environment. Create a new one.'
98+
)
9399
new_code_interpreter = Extension.from_hub('code_interpreter')
94100
os.environ['CODE_INTERPRETER_EXTENSION_NAME'] = (
95101
new_code_interpreter.gca_resource.name

src/google/adk/tools/google_api_tool/googleapi_to_openapi_converter.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
from __future__ import annotations
16+
1517
import argparse
1618
import json
1719
import logging
@@ -505,11 +507,12 @@ def main():
505507
converter = GoogleApiToOpenApiConverter(args.api_name, args.api_version)
506508
converter.convert()
507509
converter.save_openapi_spec(args.output)
508-
print(
509-
f"Successfully converted {args.api_name} {args.api_version} to"
510-
" OpenAPI v3"
510+
logger.info(
511+
"Successfully converted %s %s to OpenAPI v3",
512+
args.api_name,
513+
args.api_version,
511514
)
512-
print(f"Output saved to {args.output}")
515+
logger.info("Output saved to %s", args.output)
513516
except Exception as e:
514517
logger.error("Conversion failed: %s", e)
515518
return 1

src/google/adk/tools/google_search_tool.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ async def process_llm_request(
4848
llm_request.config.tools = llm_request.config.tools or []
4949
if llm_request.model and 'gemini-1' in llm_request.model:
5050
if llm_request.config.tools:
51-
print(llm_request.config.tools)
5251
raise ValueError(
5352
'Google search tool can not be used with other tools in Gemini 1.x.'
5453
)

src/google/adk/tools/retrieval/files_retrieval.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,25 @@
1414

1515
"""Provides data for the agent."""
1616

17+
from __future__ import annotations
18+
19+
import logging
20+
1721
from llama_index.core import SimpleDirectoryReader
1822
from llama_index.core import VectorStoreIndex
1923

2024
from .llama_index_retrieval import LlamaIndexRetrieval
2125

26+
logger = logging.getLogger("google_adk." + __name__)
27+
2228

2329
class FilesRetrieval(LlamaIndexRetrieval):
2430

2531
def __init__(self, *, name: str, description: str, input_dir: str):
2632

2733
self.input_dir = input_dir
2834

29-
print(f'Loading data from {input_dir}')
35+
logger.info("Loading data from %s", input_dir)
3036
retriever = VectorStoreIndex.from_documents(
3137
SimpleDirectoryReader(input_dir).load_data()
3238
).as_retriever()

0 commit comments

Comments
 (0)
0