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

Add exception for missing system requirements #281

Merged
merged 6 commits into from
Dec 28, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install Linux System Dependencies
if: runner.os=='Linux'
run: sudo apt install graphviz

- name: Install MacOS System Dependencies
if: runner.os=='macOS'
run: brew install graphviz

- name: Install Windows System Dependencies
if: runner.os=='Windows'
run: choco install graphviz

- name: Install poetry
run: |
python -m pip install --upgrade pip
Expand All @@ -47,4 +59,4 @@ jobs:
- name: Upload coverage
# only do it for python 3.6, we don't need to do it for every version
if: ${{ matrix.python-version == '3.8' && matrix.os == 'ubuntu-latest' }}
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v2
2 changes: 1 addition & 1 deletion src/zenml/integrations/graphviz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ class GraphvizIntegration(Integration):

NAME = GRAPHVIZ
REQUIREMENTS = ["graphviz>=0.17"]

SYSTEM_REQUIREMENTS = {"graphviz":"dot"}

GraphvizIntegration.check_installation()
12 changes: 12 additions & 0 deletions src/zenml/integrations/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
from typing import Any, Dict, List, Tuple, Type, cast

import pkg_resources
import shutil

from zenml.integrations.registry import integration_registry
from zenml.logger import get_logger
from zenml.exceptions import DoesNotExistException
AlexejPenner marked this conversation as resolved.
Show resolved Hide resolved

logger = get_logger(__name__)

Expand All @@ -42,10 +44,20 @@ class Integration(metaclass=IntegrationMeta):

REQUIREMENTS: List[str] = []

SYSTEM_REQUIREMENTS: Dict[str, str] = {}

@classmethod
def check_installation(cls) -> bool:
"""Method to check whether the required packages are installed"""
try:
for req, command in cls.SYSTEM_REQUIREMENTS.items():
result = shutil.which(command)

if result is None:
raise DoesNotExistException(
f"Unable to find the required packages for {req} on your system. Please install the packages on your system and try again."
)

for r in cls.REQUIREMENTS:
pkg_resources.get_distribution(r)
logger.debug(
Expand Down