execution
dev_tool.services.execution
__all__ = ['ContainerizedExecutionStrategy', 'ExecutionStrategy', 'ExecutionStrategyProvider', 'LocalExecutionStrategy']
module-attribute
ContainerizedExecutionStrategy
Bases: ExecutionStrategy, BaseService
An execution strategy for fully containerized development.
Both Django and PostgreSQL run in Docker containers via docker-compose.
The constructor for the ContainerizedExecutionStrategy class.
Parameters:
-
configuration(ConfigManager) –The configuration manager instance.
-
project_name(str) –The name of the project.
Source code in dev_tool/services/execution/containerized.py
build_shared_app_image
A method that builds the shared app image.
Parameters:
-
force(bool, default:False) –Whether to force a rebuild even if image exists.
Source code in dev_tool/services/execution/containerized.py
cleanup
A method that cleans up temporary build context directories.
Source code in dev_tool/services/execution/containerized.py
ensure_database
A method that ensures Docker services are running.
Parameters:
-
recreate(bool, default:False) –Whether to recreate the containers.
Source code in dev_tool/services/execution/containerized.py
run_bun_command
A method that executes a Bun command in the container.
Parameters:
-
args(list[str]) –The command arguments.
-
kwargs(Any, default:{}) –Additional subprocess arguments.
Returns:
-
CompletedProcess–The completed process result.
Source code in dev_tool/services/execution/containerized.py
run_createsuperuser
A method that creates a Django superuser with environment variables.
Parameters:
Returns:
-
CompletedProcess–The completed process result.
Source code in dev_tool/services/execution/containerized.py
run_django_command
A method that executes a Django management command in the container.
Parameters:
-
args(list[str]) –The command arguments.
-
kwargs(Any, default:{}) –Additional subprocess arguments.
Returns:
-
CompletedProcess–The completed process result.
Source code in dev_tool/services/execution/containerized.py
run_pip_command
A method that executes a uv pip command in the container.
Parameters:
-
args(list[str]) –The command arguments.
-
kwargs(Any, default:{}) –Additional subprocess arguments.
Returns:
-
CompletedProcess–The completed process result.
Source code in dev_tool/services/execution/containerized.py
run_python_command
A method that executes a Python command in the container.
Parameters:
-
args(list[str]) –The command arguments.
-
kwargs(Any, default:{}) –Additional subprocess arguments.
Returns:
-
CompletedProcess–The completed process result.
Source code in dev_tool/services/execution/containerized.py
run_sass_command
A method that executes a Sass command in the container.
Parameters:
-
args(list[str]) –The command arguments.
-
kwargs(Any, default:{}) –Additional subprocess arguments.
Returns:
-
CompletedProcess–The completed process result.
Source code in dev_tool/services/execution/containerized.py
run_seed
A method that runs the database seeding script in the container.
Parameters:
-
seed_script(Path) –The path to the seed script.
Source code in dev_tool/services/execution/containerized.py
run_shell_script
A method that executes a Django shell script in the container.
Parameters:
-
script(str) –The Python script to execute in Django shell.
-
kwargs(Any, default:{}) –Additional subprocess arguments.
Returns:
-
CompletedProcess–The completed process result.
Source code in dev_tool/services/execution/containerized.py
LocalExecutionStrategy
Bases: ExecutionStrategy
An execution strategy for local development with only the database in Docker.
This is the legacy mode where Django runs locally and only PostgreSQL runs in a container.
The constructor for the LocalExecutionStrategy class.
Parameters:
-
docker_service(DockerServiceProtocol) –The Docker service for container management.
Source code in dev_tool/services/execution/local.py
cleanup
ensure_database
A method that ensures the database container is available.
Parameters:
-
recreate(bool, default:False) –Whether to recreate the database container.
Source code in dev_tool/services/execution/local.py
run_bun_command
A method that executes a Bun command locally.
Parameters:
-
args(list[str]) –The command arguments.
-
kwargs(Any, default:{}) –Additional subprocess arguments.
Returns:
-
CompletedProcess–The completed process result.
Source code in dev_tool/services/execution/local.py
run_django_command
A method that executes a Django management command locally.
Parameters:
-
args(list[str]) –The command arguments.
-
kwargs(Any, default:{}) –Additional subprocess arguments.
Returns:
-
CompletedProcess–The completed process result.
Source code in dev_tool/services/execution/local.py
run_pip_command
A method that executes a uv pip command locally.
Parameters:
-
args(list[str]) –The command arguments.
-
kwargs(Any, default:{}) –Additional subprocess arguments.
Returns:
-
CompletedProcess–The completed process result.
Source code in dev_tool/services/execution/local.py
run_python_command
A method that executes a Python command locally.
Parameters:
-
args(list[str]) –The command arguments.
-
kwargs(Any, default:{}) –Additional subprocess arguments.
Returns:
-
CompletedProcess–The completed process result.
Source code in dev_tool/services/execution/local.py
run_sass_command
A method that executes a Sass command locally.
Parameters:
-
args(list[str]) –The command arguments.
-
kwargs(Any, default:{}) –Additional subprocess arguments.
Returns:
-
CompletedProcess–The completed process result.
Source code in dev_tool/services/execution/local.py
run_seed
A method that runs the database seeding script locally.
Parameters:
-
seed_script(Path) –The path to the seed script.
Source code in dev_tool/services/execution/local.py
run_shell_script
A method that executes a Django shell script locally.
Parameters:
-
script(str) –The Python script to execute in Django shell.
-
kwargs(Any, default:{}) –Additional subprocess arguments.
Returns:
-
CompletedProcess–The completed process result.
Source code in dev_tool/services/execution/local.py
ExecutionStrategyProvider
A provider class for managing the singleton ExecutionStrategy instance.
This class centralizes strategy creation to avoid duplicate logic scattered across multiple services.
configure
classmethod
A method that configures the provider with required dependencies.
Parameters:
-
docker_service(DockerServiceProtocol) –The Docker service for container management.
Source code in dev_tool/services/execution/provider.py
get
classmethod
A method that returns the singleton ExecutionStrategy instance.
Returns:
-
ExecutionStrategy–The ExecutionStrategy instance.
Source code in dev_tool/services/execution/provider.py
is_containerized
classmethod
A method that checks if the current strategy is containerized.
Returns:
-
bool–True if containerized, False otherwise.
Source code in dev_tool/services/execution/provider.py
ExecutionStrategy
Bases: ABC
An abstract base class defining the interface for execution strategies.
This class allows swapping between containerized and local execution without scattering conditionals throughout the codebase.
cleanup
abstractmethod
ensure_database
abstractmethod
A method that ensures the database is available.
Parameters:
-
recreate(bool, default:False) –Whether to recreate the database container.
run_bun_command
abstractmethod
A method that executes a Bun command.
Parameters:
-
args(list[str]) –The command arguments.
-
kwargs(Any, default:{}) –Additional subprocess arguments.
Returns:
-
CompletedProcess–The completed process result.
Source code in dev_tool/services/execution/strategy.py
run_django_command
abstractmethod
A method that executes a Django management command.
Parameters:
-
args(list[str]) –The command arguments.
-
kwargs(Any, default:{}) –Additional subprocess arguments.
Returns:
-
CompletedProcess–The completed process result.
Source code in dev_tool/services/execution/strategy.py
run_pip_command
abstractmethod
A method that executes a pip command.
Parameters:
-
args(list[str]) –The command arguments.
-
kwargs(Any, default:{}) –Additional subprocess arguments.
Returns:
-
CompletedProcess–The completed process result.
Source code in dev_tool/services/execution/strategy.py
run_python_command
abstractmethod
A method that executes a Python command.
Parameters:
-
args(list[str]) –The command arguments.
-
kwargs(Any, default:{}) –Additional subprocess arguments.
Returns:
-
CompletedProcess–The completed process result.
Source code in dev_tool/services/execution/strategy.py
run_sass_command
abstractmethod
A method that executes a Sass command.
Parameters:
-
args(list[str]) –The command arguments.
-
kwargs(Any, default:{}) –Additional subprocess arguments.
Returns:
-
CompletedProcess–The completed process result.
Source code in dev_tool/services/execution/strategy.py
run_seed
abstractmethod
A method that runs the database seeding script.
Parameters:
-
seed_script(Path) –The path to the seed script.
run_shell_script
abstractmethod
A method that executes a Django shell script.
Parameters:
-
script(str) –The Python script to execute in Django shell.
-
kwargs(Any, default:{}) –Additional subprocess arguments.
Returns:
-
CompletedProcess–The completed process result.