Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 25 additions & 21 deletions src/google/adk/code_executors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,30 @@
'BuiltInCodeExecutor',
'CodeExecutorContext',
'UnsafeLocalCodeExecutor',
'VertexAiCodeExecutor',
'ContainerCodeExecutor',
]

try:
from .vertex_ai_code_executor import VertexAiCodeExecutor

__all__.append('VertexAiCodeExecutor')
except ImportError:
logger.debug(
'The Vertex sdk is not installed. If you want to use the Vertex Code'
' Interpreter with agents, please install it. If not, you can ignore this'
' warning.'
)

try:
from .container_code_executor import ContainerCodeExecutor

__all__.append('ContainerCodeExecutor')
except ImportError:
logger.debug(
'The docker sdk is not installed. If you want to use the Container Code'
' Executor with agents, please install it. If not, you can ignore this'
' warning.'
)

def __getattr__(name: str):
if name == 'VertexAiCodeExecutor':
try:
from .vertex_ai_code_executor import VertexAiCodeExecutor

return VertexAiCodeExecutor
except ImportError as e:
raise ImportError(
'VertexAiCodeExecutor requires additional dependencies. '
'Please install with: pip install "google-adk[extensions]"'
) from e
elif name == 'ContainerCodeExecutor':
try:
from .container_code_executor import ContainerCodeExecutor

return ContainerCodeExecutor
except ImportError as e:
raise ImportError(
'ContainerCodeExecutor requires additional dependencies. '
'Please install with: pip install "google-adk[extensions]"'
) from e
raise AttributeError(f"module '{__name__}' has no attribute '{name}'")