Skip to content

Commit

Permalink
Turn Docker into an optional dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
antepusic committed Sep 21, 2023
1 parent 4709478 commit 67ff0c4
Show file tree
Hide file tree
Showing 5 changed files with 852 additions and 909 deletions.
10 changes: 8 additions & 2 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 @@ -86,7 +90,7 @@ def wait_for_port(


def wait_for_docker_container(
container: "docker.Container", delay: float = 0.01, timeout: float = 5.0, backoff: int = 2
container, delay: float = 0.01, timeout: float = 5.0, backoff: int = 2
) -> None:
"""Wait for a Docker container to enter the status `running`.
Expand Down Expand Up @@ -239,6 +243,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

0 comments on commit 67ff0c4

Please sign in to comment.