Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions python_on_whales/components/compose/cli_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,7 @@ def up(
pull: Literal["always", "missing", "never", None] = ...,
stream_logs: Literal[True] = ...,
wait_timeout: Optional[int] = ...,
dependencies: bool = True,
) -> Iterable[Tuple[str, bytes]]: ...

@overload
Expand All @@ -993,6 +994,7 @@ def up(
pull: Literal["always", "missing", "never", None] = ...,
stream_logs: Literal[False] = ...,
wait_timeout: Optional[int] = ...,
dependencies: bool = True,
) -> None: ...

def up(
Expand All @@ -1017,6 +1019,7 @@ def up(
pull: Literal["always", "missing", "never", None] = None,
stream_logs: bool = False,
wait_timeout: Optional[int] = None,
dependencies: bool = True,
):
"""Start the containers.

Expand Down Expand Up @@ -1062,6 +1065,7 @@ def up(
See [the streaming guide](https://gabrieldemarmiesse.github.io/python-on-whales/user_guide/docker_run/#stream-the-output) if you are
not familiar with the streaming of logs in Python-on-whales.
wait_timeout: Maximum duration to wait for the project to be running|healthy
dependencies: Also start linked services.
"""
if quiet and stream_logs:
raise ValueError(
Expand All @@ -1085,6 +1089,7 @@ def up(
full_cmd.add_flag("--no-start", not start)
full_cmd.add_flag("--remove-orphans", remove_orphans)
full_cmd.add_flag("--renew-anon-volumes", renew_anon_volumes)
full_cmd.add_flag("--no-deps", not dependencies)
full_cmd.add_simple_arg("--pull", pull)

if no_attach_services is not None:
Expand Down
26 changes: 26 additions & 0 deletions tests/python_on_whales/components/test_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,32 @@ def test_docker_compose_up_down():
assert docker.compose.ps() == []


@pytest.mark.parametrize(
"dependencies_value, expected_running_containers", [(True, 2), (False, 1)]
)
def test_docker_compose_up_dependencies(
dependencies_value, expected_running_containers
):
docker = DockerClient(
compose_files=[
PROJECT_ROOT / "tests/python_on_whales/components/dummy_compose.yml"
],
compose_compatibility=True,
)

try:
docker.compose.up(
["busybox-2-electric-boogaloo"],
dependencies=dependencies_value,
detach=True,
)
running_containers = docker.compose.ps()
finally:
docker.compose.down(timeout=1)

assert len(running_containers) == expected_running_containers


def test_docker_compose_up_down_streaming():
docker = DockerClient(
compose_files=[
Expand Down