class UbuntuDockerRuntime(DockerRuntime):
A specialized Docker runtime for Ubuntu-based environments.
This runtime includes specific configurations and setup for Ubuntu containers, including proper Python path handling and environment setup. It provides methods for executing Python files, managing the container lifecycle, and handling file operations within the Ubuntu container.
Parameters:
def __init__(
self,
image: str,
port: int = 0,
remove: bool = True,
python_path: str = '/usr/bin/python3',
**kwargs
):
Initialize the Ubuntu Docker Runtime.
Parameters:
def add(
self,
funcs: Union[FunctionTool, List[FunctionTool]],
entrypoint: str,
redirect_stdout: bool = False,
arguments: Optional[dict] = None
):
Add functions to the runtime with Ubuntu-specific modifications.
Returns:
Self for method chaining
def _setup_default_mounts(self):
Setup default volume mounts for the container.
This method can be extended to add Ubuntu-specific volume mounts.
def build(self, time_out: int = 15):
Build and initialize the Ubuntu container with proper setup.
Parameters:
Returns:
Self for method chaining
def exec_python_file(
self,
local_file_path: str,
container_path: Optional[str] = None,
args: Optional[List[str]] = None,
env: Optional[dict] = None,
callback: Optional[Callable[[str], None]] = None
):
Execute a Python file inside the Docker container.
Parameters:
def _create_archive_from_file(self, file_path: Union[str, Path]):
Create a tar archive from a single file for docker.put_archive().
Parameters:
Returns:
bytes: The tar archive as bytes