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

Conversation

kamalesh0406
Copy link
Contributor

Pre-requisites

Please ensure you have done the following:

  • I have read the CONTRIBUTING.md document.
  • If my change requires a change to the documentation, I have updated the documentation accordingly.
  • I have added tests to cover my changes.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Describe changes

Briefly describe the changes you have introduced.

I have modified the check_installation function and the Integration class to look for missing system requirements particularly pertaining to the graphviz integration. The new code raises an Exception during zenml init were it mentions the library whose package is missing from the system. I tried to make it raise the error during zenml example run but for that to be done the changes should be done in example cli and it was mentioned in the following issue #266 that an override for check_installation is preferable.

@CLAassistant
Copy link

CLAassistant commented Dec 25, 2021

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@AlexejPenner AlexejPenner left a comment

Choose a reason for hiding this comment

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

Overall, the code changes look good to me. I’m away from my machine so I can’t verify functionality right now. I added a small change request in the comments regarding the error message.

Thanks a lot for your contribution Kamalesh☺️

result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, shell=True)
if result.returncode!=0:
raise DoesNotExistException(
f"Unable to find linux/unix installation of {req}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

In my opinion this message should be os - agnostic. Maybe also add a sentence on what the user should do to fix this. Maybe a second sentence like: “Please install the package and retry.”

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, even I was thinking about this. I will try to use platform to print a more OS-specific message. The only issue is platform.system() prints 'Darwin' for macOS and that might confuse the user at times.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Alternativly, you could also just not mention the platform at all. The user already knows his platform and can find the appropriate way to install the package.

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 will do that.

@michael-zenml
Copy link
Contributor

michael-zenml commented Dec 25, 2021

I like the implementation using the additional dict of system requirements! We might consider using shutil.which(...) to check if a command exists without actually running it using subprocess.run(...), which would allow us to simplify the system requirements to ["dot"] (without the -V).

@kamalesh0406
Copy link
Contributor Author

I like the implementation using the additional dict of system requirements! We might consider using shutil.which(...) to check if a command exists without actually running it using subprocess.run(...), which would allow us to simplify the system requirements to ["dot"] (without the -V).

Thank you for the suggestion, I will change the subprocess to shutil.which .

@AlexejPenner
Copy link
Collaborator

Makes sense that we have failing tests now, as they also have a dependency on check_installation. For the scope of this bugfix it might make sense to hard code the installation of graphviz on the level of our github actions. In the long run we could then maybe have a feature ticket to implement this in a more generic way for all possible future “System requirements” as well.

Do you need any additional guidance regarding our github actions?

@kamalesh0406
Copy link
Contributor Author

Makes sense that we have failing tests now, as they also have a dependency on check_installation. For the scope of this bugfix it might make sense to hard code the installation of graphviz on the level of our github actions. In the long run we could then maybe have a feature ticket to implement this in a more generic way for all possible future “System requirements” as well.

Do you need any additional guidance regarding our github actions?

So the idea is to now ensure that graphviz is installed on the system that the github actions is testing? Please do correct me if I am wrong.

@kamalesh0406
Copy link
Contributor Author

I have modified the error message, subprocess library and the github actions as well in the new commit.

@AlexejPenner
Copy link
Collaborator

I have modified the error message, subprocess library and the github actions as well in the new commit.

Thanks Kamalesh. I don’t see any changes on the github actions within your commit. I think you may have forgotten to commit or push your changes within the .github folder?

@kamalesh0406
Copy link
Contributor Author

I have modified the error message, subprocess library and the github actions as well in the new commit.

Thanks Kamalesh. I don’t see any changes on the github actions within your commit. I think you may have forgotten to commit or push your changes within the .github folder?

Yup sorry I forgot to push them. I have modified the commit and pushed it again.

@@ -24,6 +24,14 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install System Dependencies
Copy link
Collaborator

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
Collaborator

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. :)

@htahir1
Copy link
Contributor

htahir1 commented Dec 27, 2021

@kamalesh0406 In order to fix these linting issues, we have a script in the scripts folder called format.sh. Run it as follows:

cd zenml/
poetry run bash scripts/format.sh

or simply:

./scripts/format.sh

You can also run linting as follows:

poetry run bash scripts/lint.sh
poetry run bash scripts/check-spelling.sh

And tests as follows:

poetry run bash scripts/test-coverage-xml.sh

I'll add this to the CONTRIBUTING.md for future reference

@AlexejPenner
Copy link
Collaborator

@kamalesh0406 Sorry for pushing directly onto your repo, I must have pressed the wrong button, was just gonna add it as a suggestion. I think now there's just a newline missing at the end of the file before we can merge

@kamalesh0406
Copy link
Contributor Author

Okay I will check it and push the changes.

@kamalesh0406
Copy link
Contributor Author

kamalesh0406 commented Dec 27, 2021

I am not able to recreate the linting issue on my local, can you specify the exact issue? The github actions output is not very clear as well.

@AlexejPenner
Copy link
Collaborator

AlexejPenner commented Dec 27, 2021

I am not able to recreate the linting issue on my local, can you specify the exact issue? The github actions output is not very clear as well.

Locally within your repo you should be able to just run poetry run bash scripts/format.sh - this will fix the issue for you. Then you just need to commit and push the file.

And yeah, I agree the logs in the Github actions could be a bit more specific. In this case the file src/zenml/integrations/integration.py is missing a newline at the end.

@AlexejPenner
Copy link
Collaborator

@kamalesh0406 Looks great, thanks for your contribution 🙏

@AlexejPenner AlexejPenner merged commit f107622 into zenml-io:main Dec 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants