-
Notifications
You must be signed in to change notification settings - Fork 605
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
Capturing error in loading a specific config class better and bumping log level #5213
Conversation
WalkthroughThe changes primarily involve enhancing error handling and logging within the Changes
Poem
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
Documentation and Community
|
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
🧹 Outside diff range and nitpick comments (1)
fiftyone/core/runs.py (1)
138-140
: LGTM! Enhanced error handling and logging.The changes improve error visibility by:
- Capturing and logging specific exception details
- Upgrading log level from debug to warning for better visibility
- Including both the class name and error reason in the message
Consider using string formatting with parentheses for better readability:
- f"Unable to load {config_cls} due to {e}; falling back to base class" + f"Unable to load {config_cls} (reason: {e}); falling back to base class"
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.
LGTM
13903a1
to
8929baa
Compare
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: 1
🧹 Outside diff range and nitpick comments (1)
fiftyone/core/runs.py (1)
Line range hint
1-1024
: Consider standardizing error handling patternsThe codebase would benefit from a more consistent error handling strategy:
- Standardize when to use debug vs warning log levels
- Consider adding version checks consistently where appropriate
- Establish a pattern for including exception details in log messages
Consider creating an error handling utility module that provides:
- Standardized logging functions with consistent formatting
- Version compatibility checks
- Exception type categorization
This would improve maintainability and ensure consistent error reporting across the codebase.🧰 Tools
🪛 Ruff (0.8.2)
138-138: Local variable
e
is assigned to but never usedRemove assignment to unused variable
e
(F841)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
fiftyone/core/runs.py
(1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
fiftyone/core/runs.py
138-138: Local variable e
is assigned to but never used
Remove assignment to unused variable e
(F841)
except Exception as e: | ||
logger.warning( | ||
f"Unable to load {config_cls}; falling back to base class", | ||
exc_info=True, |
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.
🛠️ Refactor suggestion
Enhance exception handling and logging
The current exception handling could be improved in several ways:
- The caught exception is not used in the log message
- The catch block uses a broad Exception type
- The warning message could be more informative
Consider applying this improvement:
- except Exception as e:
+ except (ImportError, AttributeError) as e:
logger.warning(
- f"Unable to load {config_cls}; falling back to base class",
+ f"Unable to load {config_cls}; falling back to base class. Error: {str(e)}",
exc_info=True,
)
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
except Exception as e: | |
logger.warning( | |
f"Unable to load {config_cls}; falling back to base class", | |
exc_info=True, | |
except (ImportError, AttributeError) as e: | |
logger.warning( | |
f"Unable to load {config_cls}; falling back to base class. Error: {str(e)}", | |
exc_info=True, |
🧰 Tools
🪛 Ruff (0.8.2)
138-138: Local variable e
is assigned to but never used
Remove assignment to unused variable e
(F841)
What changes are proposed in this pull request?
Loading brain results can error out and the error tends to be hidden with the current logging level and exception handling. This PR addresses both these issues.
How is this patch tested? If it is not, please explain why.
Not tested as its a logging update.
Release Notes
Is this a user-facing change that should be mentioned in the release notes?
notes for FiftyOne users.
(Details in 1-2 sentences. You can just refer to another PR with a description
if this PR is part of a larger change.)
What areas of FiftyOne does this PR affect?
fiftyone
Python library changesSummary by CodeRabbit
Bug Fixes
Chores