Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[main < T279] Turn Docker into an optional dependency #279

Merged
merged 3 commits into from
Sep 21, 2023
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
12 changes: 8 additions & 4 deletions gqlalchemy/instance_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@
from enum import Enum
from typing import Any, Dict, Union

import docker
try:
import docker
except ModuleNotFoundError:
docker = None
import psutil

from gqlalchemy.exceptions import (
GQLAlchemyWaitForConnectionError,
GQLAlchemyWaitForDockerError,
GQLAlchemyWaitForPortError,
raise_if_not_imported,
)
from gqlalchemy.vendors.memgraph import Memgraph

Expand Down Expand Up @@ -85,9 +89,7 @@ def wait_for_port(
delay *= backoff


def wait_for_docker_container(
container: "docker.Container", delay: float = 0.01, timeout: float = 5.0, backoff: int = 2
) -> None:
def wait_for_docker_container(container, delay: float = 0.01, timeout: float = 5.0, backoff: int = 2) -> None:
"""Wait for a Docker container to enter the status `running`.

Args:
Expand Down Expand Up @@ -239,6 +241,8 @@ class MemgraphInstanceDocker(MemgraphInstance):
def __init__(
self, docker_image: DockerImage = DockerImage.MEMGRAPH, docker_image_tag: str = DOCKER_IMAGE_TAG_LATEST, **data
) -> None:
raise_if_not_imported(dependency=docker, dependency_name="docker")

super().__init__(**data)
self.docker_image = docker_image
self.docker_image_tag = docker_image_tag
Expand Down
Loading