Skip to content

factory

dev_tool.services.execution.factory

ExecutionStrategyFactory

A factory class for creating the appropriate execution strategy.

This class reads the containerized setting from pyproject.toml and returns the corresponding strategy instance.

create staticmethod

A factory method that creates the appropriate execution strategy.

Parameters:

  • configuration (ConfigManager) –

    The configuration manager instance.

  • docker_service (DockerService) –

    The Docker service for container management.

Returns:

Source code in dev_tool/services/execution/factory.py
@staticmethod
def create(configuration: ConfigManager, docker_service: DockerService) -> ExecutionStrategy:
    """
    A factory method that creates the appropriate execution strategy.

    :param configuration: The configuration manager instance.
    :param docker_service: The Docker service for container management.
    :return: The appropriate execution strategy instance.
    """

    containerized = configuration.pyproject.get_dev_tool_config().get('containerized', False)
    project_name = configuration.get_project_name()

    if containerized:
        return ContainerizedExecutionStrategy(
            configuration=configuration,
            project_name=project_name
        )

    return LocalExecutionStrategy(docker_service=docker_service)