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 2 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
10 changes: 9 additions & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install System Dependencies
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the correct syntax here would be to name each condition separately:

    - name: condition no 1
      if: condition_1=true
      run: script for condition 1
   - name: condition 2
      if: condition_2=true
      run: script for condition 2

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, that makes sense. I have pushed the changes, sorry for the inconvenience.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test failed since I used double quotes instead of using single quotes for specifying the system.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all your efforts. Looks good to me so far 😊

Are you able to see the logs of the Github actions? There seem to be some linting issues. If you have no access I can paste the logs here ☺️

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup I have modified my code according to the error. :)

if: runner.os=="Linux"
run: sudo apt install graphviz
if: runner.os=="macOS"
run: brew install graphviz
if: runner.os=="Windows"
run: choco install graphviz

- name: Install poetry
run: |
python -m pip install --upgrade pip
Expand All @@ -47,4 +55,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==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