-
Notifications
You must be signed in to change notification settings - Fork 64
feat: update modelres #278
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
Summary of ChangesHello @shijinpjlab, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a significant refactoring of the evaluation result handling within the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request introduces a significant and beneficial refactoring of the ModelRes data structure, simplifying the handling of evaluation results. The changes in dingo/exec/local.py and dingo/io/output/result_info.py correctly adapt to this new structure. However, the refactoring is incomplete and introduces a critical issue: most of the rule implementations in dingo/model/rule/rule_common.py have not been updated to use the new ModelRes format. This will lead to runtime failures. Additionally, I've suggested some minor code cleanup by removing commented-out code blocks to improve readability.
| if key in existing_item.eval_details: | ||
| existing_item.eval_details[key].merge(value) | ||
| # 第一层是字段名,如果不存在,则创建副本 | ||
| existing_item.eval_details[key].extend(value) | ||
| # 第一层是字段名,如果不存在,则直接赋值 | ||
| else: | ||
| existing_item.eval_details[key] = value.copy() | ||
| existing_item.eval_details[key] = value |
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.
When merging eval_details, the value list is assigned directly. While this is likely safe because new_item is transient, if value were to be modified elsewhere, it would affect existing_item.eval_details[key] as they would point to the same list object. Using value.copy() would prevent such potential side effects and make the code more robust against future changes.
| if key in existing_item.eval_details: | |
| existing_item.eval_details[key].merge(value) | |
| # 第一层是字段名,如果不存在,则创建副本 | |
| existing_item.eval_details[key].extend(value) | |
| # 第一层是字段名,如果不存在,则直接赋值 | |
| else: | |
| existing_item.eval_details[key] = value.copy() | |
| existing_item.eval_details[key] = value | |
| if key in existing_item.eval_details: | |
| existing_item.eval_details[key].extend(value) | |
| # 第一层是字段名,如果不存在,则直接赋值 | |
| else: | |
| existing_item.eval_details[key] = value.copy() |
| # res.eval_status = True | ||
| # res.eval_details = { | ||
| # "label": [f"{cls.metric_type}.{cls.__name__}"], | ||
| # "metric": [cls.__name__], | ||
| # "reason": [content[-100:]] | ||
| # } | ||
| res.status = True | ||
| res.label = [f"{cls.metric_type}.{cls.__name__}"] | ||
| res.reason = [content[-100:]] | ||
| else: | ||
| res.eval_details = { | ||
| "label": [QualityLabel.QUALITY_GOOD] | ||
| } | ||
| # res.eval_details = { | ||
| # "label": [QualityLabel.QUALITY_GOOD] | ||
| # } | ||
| res.label = [QualityLabel.QUALITY_GOOD] |
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.
| # res.eval_status = True | ||
| # res.eval_details = { | ||
| # "label": [f"{cls.metric_type}.{cls.__name__}"], | ||
| # "metric": [cls.__name__], | ||
| # "reason": list(set(matches)) | ||
| # } | ||
| res.status = True | ||
| res.label = [f"{cls.metric_type}.{cls.__name__}"] | ||
| res.reason = list(set(matches)) | ||
| else: | ||
| res.eval_details = { | ||
| "label": [QualityLabel.QUALITY_GOOD] | ||
| } | ||
| # res.eval_details = { | ||
| # "label": [QualityLabel.QUALITY_GOOD] | ||
| # } | ||
| res.label = [QualityLabel.QUALITY_GOOD] |
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.
dingo/model/modelres.py
Outdated
| } | ||
|
|
||
|
|
||
| class ModelRes(BaseModel): |
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.
EvalDetail这个class不用了么
No description provided.