-
Notifications
You must be signed in to change notification settings - Fork 510
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
show panel render error #4333
base: py-panels-develop
Are you sure you want to change the base?
show panel render error #4333
Conversation
WalkthroughThe changes made across the application aim to enhance robustness and user experience by introducing safer access patterns and improved error handling in custom panel functionalities. These updates ensure smoother interactions and increased fault tolerance in the application's operational flow. Changes
Tip New Features and ImprovementsReview SettingsIntroduced new personality profiles for code reviews. Users can now select between "Chill" and "Assertive" review tones to tailor feedback styles according to their preferences. The "Assertive" profile posts more comments and nitpicks the code more aggressively, while the "Chill" profile is more relaxed and posts fewer comments. AST-based InstructionsCodeRabbit offers customizing reviews based on the Abstract Syntax Tree (AST) pattern matching. Read more about AST-based instructions in the documentation. Community-driven AST-based RulesWe are kicking off a community-driven initiative to create and share AST-based rules. Users can now contribute their AST-based rules to detect security vulnerabilities, code smells, and anti-patterns. Please see the ast-grep-essentials repository for more information. New Static Analysis ToolsWe are continually expanding our support for static analysis tools. We have added support for Tone SettingsUsers can now customize CodeRabbit to review code in the style of their favorite characters or personalities. Here are some of our favorite examples:
Revamped Settings PageWe have redesigned the settings page for a more intuitive layout, enabling users to find and adjust settings quickly. This change was long overdue; it not only improves the user experience but also allows our development team to add more settings in the future with ease. Going forward, the changes to Miscellaneous
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 as PR comments)
Additionally, you can add CodeRabbit Configration 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: 1
executeOperator(props.onLoad, { panel_id: panelId }, (result) => { | ||
const { error: onLoadError } = result; | ||
setPanelState((s) => ({ ...s, onLoadError, loaded: 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.
Ensure proper error handling in asynchronous callbacks.
The current implementation of the error handling within the executeOperator
callback does not account for potential exceptions that might be thrown by the setPanelState
function. It's recommended to wrap the callback body in a try-catch block to handle such exceptions gracefully.
executeOperator(props.onLoad, { panel_id: panelId }, (result) => {
try {
const { error: onLoadError } = result;
setPanelState((s) => ({ ...s, onLoadError, loaded: true }));
+ } catch (error) {
+ console.error('Failed to update panel state:', error);
+ }
});
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.
executeOperator(props.onLoad, { panel_id: panelId }, (result) => { | |
const { error: onLoadError } = result; | |
setPanelState((s) => ({ ...s, onLoadError, loaded: true })); | |
}); | |
executeOperator(props.onLoad, { panel_id: panelId }, (result) => { | |
try { | |
const { error: onLoadError } = result; | |
setPanelState((s) => ({ ...s, onLoadError, loaded: true })); | |
} catch (error) { | |
console.error('Failed to update panel state:', error); | |
} | |
}); |
39de11c
to
adb1b0b
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: 3
Outside diff range and nitpick comments (5)
app/packages/operators/src/useCustomPanelHooks.ts (4)
Line range hint
16-26
: Avoid usingFunction
as a type for better type safety.- onLoad?: Function; - onChange?: Function; - onUnLoad?: Function; - onChangeCtx?: Function; - onViewChange?: Function; - onChangeView?: Function; - onChangeDataset?: Function; - onChangeCurrentSample?: Function; - onChangeSelected?: Function; - onChangeSelectedLabels?: Function; - onChangeExtendedSelection?: Function; + onLoad?: () => void; + onChange?: () => void; + onUnLoad?: () => void; + onChangeCtx?: () => void; + onViewChange?: () => void; + onChangeView?: () => void; + onChangeDataset?: () => void; + onChangeCurrentSample?: () => void; + onChangeSelected?: () => void; + onChangeSelectedLabels?: () => void; + onChangeExtendedSelection?: () => void;
Line range hint
38-42
: Specify explicit types instead of usingany
.- panelState: any; - handlePanelStateChange: Function; - handlePanelStatePathChange: Function; - data: any; - panelSchema: any; + panelState: PanelStateType; // Define PanelStateType based on the expected structure + handlePanelStateChange: (newState: PanelStateType) => void; + handlePanelStatePathChange: (path: string, value: any, schema: SchemaType) => void; // Define SchemaType based on the expected structure + data: DataType; // Define DataType based on the expected structure + panelSchema: SchemaType;
Line range hint
48-48
: Add missing dependencies touseEffect
to ensure correct re-rendering.- }, [value, operator]); + }, [value, operator, triggerCtxChangedEvent]);
Line range hint
156-156
: Specify explicit types instead of usingany
.- function getPanelViewData(panelState: any): any { + function getPanelViewData(panelState: PanelStateType): DataType {app/packages/operators/src/built-in-operators.ts (1)
Line range hint
908-908
: Avoid usingeval()
due to security risks and performance issues.- return eval(src.trim()); + // Consider using a safer alternative to eval if possible, such as a dedicated parsing library or new Function() if absolutely necessary.
Review Details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (2)
- app/packages/operators/src/built-in-operators.ts (2 hunks)
- app/packages/operators/src/useCustomPanelHooks.ts (1 hunks)
Additional Context Used
Biome (40)
app/packages/operators/src/built-in-operators.ts (20)
875-875: This variable implicitly has the any type.
19-28: Some named imports are only used as types.
367-367: Don't use '{}' as a type.
421-421: Don't use '{}' as a type.
446-446: Don't use '{}' as a type.
468-468: Don't use '{}' as a type.
528-528: Don't use '{}' as a type.
616-616: Don't use '{}' as a type.
650-650: Don't use '{}' as a type.
738-738: Don't use '{}' as a type.
796-796: Don't use '{}' as a type.
812-812: Don't use '{}' as a type.
828-828: Don't use '{}' as a type.
844-844: Don't use '{}' as a type.
860-860: Don't use '{}' as a type.
899-899: Don't use '{}' as a type.
908-908: eval() exposes to security risks and performance issues.
919-919: Don't use '{}' as a type.
942-942: Don't use '{}' as a type.
998-998: Don't use '{}' as a type.
app/packages/operators/src/useCustomPanelHooks.ts (20)
38-38: Unexpected any. Specify a different type.
41-41: Unexpected any. Specify a different type.
42-42: Unexpected any. Specify a different type.
156-156: Unexpected any. Specify a different type.
16-16: Don't use 'Function' as a type.
17-17: Don't use 'Function' as a type.
18-18: Don't use 'Function' as a type.
19-19: Don't use 'Function' as a type.
20-20: Don't use 'Function' as a type.
21-21: Don't use 'Function' as a type.
22-22: Don't use 'Function' as a type.
23-23: Don't use 'Function' as a type.
24-24: Don't use 'Function' as a type.
25-25: Don't use 'Function' as a type.
26-26: Don't use 'Function' as a type.
39-39: Don't use 'Function' as a type.
40-40: Don't use 'Function' as a type.
48-48: This hook does not specify all of its dependencies: panelId
48-48: This hook does not specify all of its dependencies: triggerCtxChangedEvent
109-109: This hook does not specify all of its dependencies: panelState?.loaded
Path-based Instructions (2)
app/packages/operators/src/useCustomPanelHooks.ts (1)
Pattern
**/*.{ts,tsx}
: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.app/packages/operators/src/built-in-operators.ts (1)
Pattern
**/*.{ts,tsx}
: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.
Additional comments not posted (2)
app/packages/operators/src/useCustomPanelHooks.ts (2)
111-114
: Ensure proper error handling in asynchronous callbacks.
Line range hint
48-48
: Ensure all dependencies are specified inuseEffect
.
@@ -108,8 +108,10 @@ export function useCustomPanelHooks(props: CustomPanelProps): CustomPanelHooks { | |||
|
|||
useEffect(() => { |
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.
Ensure all dependencies are specified in useEffect
.
- }, [panelId, props.onLoad, props.onUnLoad]);
+ }, [panelId, props.onLoad, props.onUnLoad, panelState?.loaded]);
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.
useEffect(() => { | |
useEffect(() => { | |
}, [panelId, props.onLoad, props.onUnLoad, panelState?.loaded]); |
const { | ||
params, | ||
operator_uri, | ||
on_success, | ||
on_error, | ||
on_cancel, | ||
} = ctx.params; |
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.
Ensure proper error handling and user feedback in asynchronous operations.
+ if (result.error) {
+ console.error('Operation failed:', result.error);
+ // Optionally, provide user feedback here
+ }
Committable suggestion was skipped due low confidence.
@@ -871,7 +871,7 @@ function useUpdatePanelStatePartial(local?: boolean) { | |||
targetParam = targetParam || targetPartial; | |||
setTimeout(() => { | |||
setPanelStateById(ctx.getCurrentPanelId(), (current = {}) => { | |||
const currentCustomPanelState = current[targetPartial] || {}; | |||
const currentCustomPanelState = current?.[targetPartial] || {}; |
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.
Specify explicit types to avoid implicit any
.
- let updatedState;
+ let updatedState: CustomPanelStateType; // Define CustomPanelStateType based on the expected structure
Committable suggestion was skipped due low confidence.
What changes are proposed in this pull request?
Show panel render method error for python panel
How is this patch tested? If it is not, please explain why.
Using an example Python panel
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