-
Notifications
You must be signed in to change notification settings - Fork 1
Better error message from load_all_metadata - see HEA-572 #182
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
Conversation
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.
Pull Request Overview
This PR improves error handling in the metadata loading process by providing more detailed error messages when bulk operations fail. The changes enhance debugging capabilities by attempting individual instance saves when bulk operations fail and reporting specific instance data that caused the failure.
- Enhanced error handling with fallback to individual instance saves when bulk operations fail
- Added primary key handling to support individual instance updates
- Improved error messages that include specific instance data and identifiers
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| from io import BytesIO | ||
|
|
||
| import django | ||
| import numpy as np |
Copilot
AI
Oct 15, 2025
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.
Consider importing numpy only when needed (e.g., from numpy import nan) since numpy is a heavy dependency and only used for np.nan replacement on line 144.
| k: v for k, v in instance.__dict__.items() if k not in ["_state", "created", "modified"] | ||
| } | ||
| raise RuntimeError( | ||
| f"Failed to create/update {model_name} instance {i} {key} from:\n{json.dumps(instance, indent=4, ensure_ascii=False)}" |
Copilot
AI
Oct 15, 2025
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.
The variable model_name is not defined in this scope. It should likely be model.__name__ or model._meta.model_name.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.