-
Notifications
You must be signed in to change notification settings - Fork 7
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
More helpful Error message #372
Conversation
for more information, see https://pre-commit.ci
WalkthroughThe pull request introduces a modification to the Changes
Poem
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
pysqa/queueadapter.py (2)
410-415
: Approve the improved error handling with minor suggestions.Good improvement to the error handling! The try-except block makes the error message more user-friendly when optional dependencies are missing. A few suggestions to make the error message even more helpful:
Consider enhancing the error message to explicitly mention the required dependencies:
- "Failed to instantiate RemoteQueue setup, probably due to missing optional dependencies" + "Failed to instantiate RemoteQueue setup. Please ensure the optional dependencies 'paramiko' and 'tqdm' are installed. You can install them using: pip install paramiko tqdm"This provides users with immediate actionable information about what packages they need to install.
410-415
: Consider updating documentation for optional dependencies.Since this change handles optional dependencies more gracefully, it would be helpful to document these requirements.
Consider:
- Adding a note in the docstring of
set_queue_adapter
about optional dependencies for different queue types- Updating the project's README or documentation to list optional dependencies for each queue adapter type
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
pysqa/queueadapter.py
(1 hunks)
🔇 Additional comments (1)
pysqa/queueadapter.py (1)
410-415
: Verify similar import patterns in the codebase.
Let's check if there are other optional dependencies that could benefit from similar error handling improvements.
✅ Verification successful
No other similar import patterns require improved error handling
The verification results show that the import of RemoteQueueAdapter
is the only instance in the codebase where optional dependencies are handled with try-except blocks for ImportError. This suggests that other imports in the codebase are for required dependencies rather than optional ones.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Search for similar import patterns and error handling in the codebase
# Look for direct imports that might be optional
rg "^from.*import" --type py
# Look for try-except blocks around imports
rg -B 2 -A 2 "try:.*\n.*import.*\n.*except.*ImportError"
# Look for other potential optional dependencies mentioned in setup files
fd "setup\.(py|cfg)" | xargs rg "extras_require"
Length of output: 5114
Script:
#!/bin/bash
# Let's try a different approach to find try-except blocks around imports
# Search for try-except blocks around imports with proper multiline support
rg -U --multiline "try:\s*\n.*?import.*?\n.*?except.*?ImportError" -g "*.py"
# Search for potential optional imports with specific patterns
rg "try:.*?import" -g "*.py"
# Look for setup.py extras_require specifically
cat setup.py
Length of output: 433
try: | ||
from pysqa.base.remote import RemoteQueueAdapter | ||
except ImportError as e: | ||
raise ImportError( | ||
"Failed to instantiate RemoteQueue setup, probably due to missing optional dependencies" | ||
) from e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a bit reluctant to add this try except statement, as the message does not add a lot more details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was only confused, since I installed pure pyiron_base to test some things and got greeted by an ImportError. I immediately checked if our feedstock is missing packages and then realized it is an optional dependency.
This is only conveyed by the code base.
However, I am fine with not having this in.
Summary by CodeRabbit