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

feat: throwing a warning when a sub-backend implementation is available but is not being used. #23489

Merged
merged 22 commits into from
Sep 21, 2023
Merged

feat: throwing a warning when a sub-backend implementation is available but is not being used. #23489

merged 22 commits into from
Sep 21, 2023

Conversation

Madjid-CH
Copy link
Contributor

PR Description

This PR is for this task
my solution is to:

  1. during the backend setting ivy.set_backend I check available sub-backend implementations by analyzing the sub backend module and put the result in a dictionary.
  2. inside the _set_backend_as_ivy I check if a given symbols has a sub backend implementation from the already populated dictionary in step 1 and if this the case we wrap the function with a wrapper that throws a warning when ever the function is used.

there's an issue which is I need to import the ivy sub backend (for example this) dynamically and analyze it symbols to do step 1 this may lead to some errors if the real sub backend(for example this) is not installed properly (missing some cuda toolkits or something like that) so either we catch the error and abort the search or we search the sub backend module without importing it (some sort of static analysis) but I didn't find a way to do the later.

@github-actions
Copy link
Contributor

Thanks for contributing to Ivy! 😊👏
Here are some of the important points from our Contributing Guidelines 📝:
1. Feel free to ignore the run_tests (1), run_tests (2), … jobs, and only look at the display_test_results job. 👀 It contains the following two sections:
- Combined Test Results: This shows the results of all the ivy tests that ran on the PR. ✔️
- New Failures Introduced: This lists the tests that are passing on main, but fail on the PR Fork. Please try to make sure that there are no such tests. 💪
2. The lint / Check formatting / check-formatting tests check for the formatting of your code. 📜 If it fails, please check the exact error message in the logs and fix the same. ⚠️🔧
3. Finally, the test-docstrings / run-docstring-tests check for the changes made in docstrings of the functions. This may be skipped, as well. 📚
Happy coding! 🎉👨‍💻

Copy link
Contributor

@vedpatwardhan vedpatwardhan left a comment

Choose a reason for hiding this comment

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

Hey @Madjid-CH, just requested a few changes, thanks 😄

ivy/func_wrapper.py Show resolved Hide resolved
ivy/utils/backend/handler.py Show resolved Hide resolved
ivy/utils/backend/handler.py Outdated Show resolved Hide resolved
ivy/utils/backend/sub_backend_handler.py Outdated Show resolved Hide resolved
ivy/utils/backend/sub_backend_handler.py Outdated Show resolved Hide resolved
ivy/utils/backend/sub_backend_handler.py Outdated Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

PR Compliance Checks

Thank you for your Pull Request! We have run several checks on this pull request in order to make sure it's suitable for merging into this project. The results are listed in the following section.

Issue Reference

In order to be considered for merging, the pull request description must refer to a specific issue number. This is described in our contributing guide and our PR template.
This check is looking for a phrase similar to: "Fixes #XYZ" or "Resolves #XYZ" where XYZ is the issue number that this PR is meant to address.

@Madjid-CH Madjid-CH changed the title Throwing a warning when a sub-backend implementation is available but is not being used. feat: throwing a warning when a sub-backend implementation is available but is not being used. Sep 13, 2023
Copy link
Contributor

@vedpatwardhan vedpatwardhan left a comment

Choose a reason for hiding this comment

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

Just requested a few more changes, thanks @Madjid-CH 😄

ivy/utils/backend/handler.py Show resolved Hide resolved
ivy/utils/backend/handler.py Outdated Show resolved Hide resolved
ivy/utils/backend/sub_backend_handler.py Outdated Show resolved Hide resolved
ivy/utils/backend/sub_backend_handler.py Outdated Show resolved Hide resolved
ivy/utils/backend/sub_backend_handler.py Outdated Show resolved Hide resolved
Copy link
Contributor

@vedpatwardhan vedpatwardhan left a comment

Choose a reason for hiding this comment

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

Almost there, just a minor change, thanks @Madjid-CH 😄

ivy/utils/backend/sub_backend_handler.py Outdated Show resolved Hide resolved
@ivy-seed ivy-seed assigned KevinUli and unassigned D0m-inic Sep 17, 2023
Copy link
Contributor

@vedpatwardhan vedpatwardhan left a comment

Choose a reason for hiding this comment

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

Hey @Madjid-CH, just a couple more comments, thanks 😄

ivy/utils/backend/handler.py Show resolved Hide resolved
ivy/utils/backend/sub_backend_handler.py Outdated Show resolved Hide resolved
Madjid Chergui added 2 commits September 18, 2023 12:30
ivy/utils/backend/sub_backend_handler.py Outdated Show resolved Hide resolved
ivy/utils/backend/handler.py Show resolved Hide resolved
Copy link
Contributor

@vedpatwardhan vedpatwardhan left a comment

Choose a reason for hiding this comment

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

Just a minor change, thanks @Madjid-CH 😄

ivy/utils/backend/sub_backend_handler.py Outdated Show resolved Hide resolved
Copy link
Contributor

@vedpatwardhan vedpatwardhan left a comment

Choose a reason for hiding this comment

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

lgtm! Feel free to merge, thanks @Madjid-CH 😄

@Madjid-CH Madjid-CH merged commit dd7dc3b into ivy-llc:main Sep 21, 2023
75 of 135 checks passed
@Madjid-CH Madjid-CH deleted the sub-backend-implementation branch September 21, 2023 09:02
iababio pushed a commit to iababio/ivy that referenced this pull request Sep 27, 2023
druvdub pushed a commit to druvdub/ivy that referenced this pull request Oct 14, 2023
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.

4 participants