Skip to content

海里数检测改为经验检测后自动检测#112

Merged
Beatrice-betty merged 1 commit into
wess09:devfrom
Beatrice-betty:dev
May 18, 2026
Merged

海里数检测改为经验检测后自动检测#112
Beatrice-betty merged 1 commit into
wess09:devfrom
Beatrice-betty:dev

Conversation

@Beatrice-betty
Copy link
Copy Markdown
Collaborator

@Beatrice-betty Beatrice-betty commented May 18, 2026

Summary by Sourcery

在危险等级评估过程中始终执行海里检测,并移除已过时的配置开关。

Enhancements:

  • 在危险等级检查期间无条件运行海里检测,而不是将其置于配置标志之后进行控制。

Chores:

  • 移除 OpsiSeaMiles 配置组、任务条目以及相关的本地化/配置条目,因为该功能不再提供给用户进行配置。
Original summary in English

Summary by Sourcery

Always perform sea miles detection during hazard leveling and remove the now-obsolete configuration toggle.

Enhancements:

  • Run sea miles detection unconditionally during the hazard leveling check instead of gating it behind a configuration flag.

Chores:

  • Remove the OpsiSeaMiles configuration group, task entry, and related localized/config entries as the feature is no longer user-configurable.

@Beatrice-betty Beatrice-betty merged commit cdc91bc into wess09:dev May 18, 2026
3 checks passed
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 18, 2026

审阅者指南(在小型 PR 上折叠显示)

审阅者指南

此 PR 使海里数检测在危险等级计算(hazard leveling)过程中始终自动运行,而不是再由配置开关控制,并在整个配置系统中移除已不再使用的 OpsiSeaMiles 配置及相关选项 / i18n 条目。

危险等级计算过程中海里数自动检测的时序图

sequenceDiagram
    participant OsHazardLeveling as os_check_leveling
    participant Logger as logger
    participant SeaMiles as detect_and_record_sea_miles

    OsHazardLeveling->>Logger: info
    Note right of Logger: 开始海里数检测

    OsHazardLeveling->>SeaMiles: detect_and_record_sea_miles
    SeaMiles-->>OsHazardLeveling: sea_miles

    alt [sea_miles is not None]
        OsHazardLeveling->>Logger: info
        Note right of Logger: 海里数检测完成: {sea_miles}
    else [sea_miles is None]
        OsHazardLeveling->>Logger: warning
        Note right of Logger: 海里数检测失败,但不影响后续流程
    end

    rect rgb(255,230,230)
        OsHazardLeveling->>SeaMiles: [exceptions during detect_and_record_sea_miles]
        OsHazardLeveling->>Logger: error
        Note right of Logger: 海里数检测异常: {e},但不影响后续流程
    end
Loading

文件级变更

变更 详情 文件
在 os_check_leveling 过程中始终运行海里数检测,而不是再通过 OpsiSeaMiles_Enable 配置开关进行控制。
  • 移除 os_check_leveling 中围绕海里数检测的 hasattr/配置开关检查。
  • 始终记录海里数检测的开始日志,并在 try/except 中调用 detect_and_record_sea_miles。
  • 保留现有的成功、失败和异常日志语义,继续将检测失败视为非致命错误。
module/os/tasks/hazard_leveling.py
从配置系统中移除 OpsiSeaMiles 配置组及所有相关选项。
  • 从 argument.yaml 中删除 OpsiSeaMiles.Enable 选项定义。
  • 从 GeneratedConfig 中移除 OpsiSeaMiles_Enable 字段,包括其默认值。
  • 从 task.yaml 的 Opsi 任务组中移除 OpsiSeaMiles,使其不再暴露为单独的任务/部分。
  • 清理相关配置模板、args JSON 和 i18n 条目,确保不再有指向 OpsiSeaMiles 的悬空引用。
module/config/argument/argument.yaml
module/config/config_generated.py
module/config/argument/task.yaml
config/template.json
module/config/argument/args.json
module/config/i18n/en-US.json
module/config/i18n/ja-JP.json
module/config/i18n/zh-CN.json
module/config/i18n/zh-MIAO.json
module/config/i18n/zh-TW.json

提示与命令

与 Sourcery 交互

  • 触发新审查: 在 Pull Request 中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 从审查评论生成 GitHub Issue: 在某条审查评论下回复,请 Sourcery 从该评论创建一个 issue。你也可以回复 @sourcery-ai issue 来基于该评论创建一个 issue。
  • 生成 Pull Request 标题: 在 Pull Request 标题的任意位置写上 @sourcery-ai,即可随时生成标题。你也可以在 Pull Request 中评论 @sourcery-ai title 来(重新)生成标题。
  • 生成 Pull Request 摘要: 在 Pull Request 正文的任意位置写上 @sourcery-ai summary,即可在指定位置随时生成 PR 摘要。你也可以在 Pull Request 中评论 @sourcery-ai summary 来(重新)生成摘要。
  • 生成审阅者指南: 在 Pull Request 中评论 @sourcery-ai guide,即可随时(重新)生成审阅者指南。
  • 一次性解决所有 Sourcery 评论: 在 Pull Request 中评论 @sourcery-ai resolve,即可将所有 Sourcery 评论标记为已解决。适用于你已经处理完所有评论且不想再看到它们时。
  • 批量驳回所有 Sourcery 审查: 在 Pull Request 中评论 @sourcery-ai dismiss,即可驳回所有现有的 Sourcery 审查。特别适用于你想从头开始新的审查时——别忘了再评论 @sourcery-ai review 以触发新审查!

自定义你的体验

访问你的 控制面板 可以:

  • 启用或禁用审查功能,例如 Sourcery 生成的 Pull Request 摘要、审阅者指南等。
  • 更改审查语言。
  • 添加、删除或编辑自定义审查说明。
  • 调整其他审查相关设置。

获取帮助

Original review guide in English
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR makes sea miles detection always run automatically during hazard leveling instead of being gated by a configuration flag, and removes the now-unused OpsiSeaMiles configuration and related options/i18n entries across the config system.

Sequence diagram for automatic sea miles detection during hazard leveling

sequenceDiagram
    participant OsHazardLeveling as os_check_leveling
    participant Logger as logger
    participant SeaMiles as detect_and_record_sea_miles

    OsHazardLeveling->>Logger: info
    Note right of Logger: 开始海里数检测

    OsHazardLeveling->>SeaMiles: detect_and_record_sea_miles
    SeaMiles-->>OsHazardLeveling: sea_miles

    alt [sea_miles is not None]
        OsHazardLeveling->>Logger: info
        Note right of Logger: 海里数检测完成: {sea_miles}
    else [sea_miles is None]
        OsHazardLeveling->>Logger: warning
        Note right of Logger: 海里数检测失败,但不影响后续流程
    end

    rect rgb(255,230,230)
        OsHazardLeveling->>SeaMiles: [exceptions during detect_and_record_sea_miles]
        OsHazardLeveling->>Logger: error
        Note right of Logger: 海里数检测异常: {e},但不影响后续流程
    end
Loading

File-Level Changes

Change Details Files
Always run sea miles detection during os_check_leveling instead of guarding it with the OpsiSeaMiles_Enable config flag.
  • Remove hasattr/config flag check around sea miles detection in os_check_leveling.
  • Always log the start of sea miles detection and call detect_and_record_sea_miles inside a try/except.
  • Preserve existing success, failure, and exception logging semantics, still treating failures as non-fatal.
module/os/tasks/hazard_leveling.py
Remove the OpsiSeaMiles configuration group and all associated options from the configuration system.
  • Delete OpsiSeaMiles.Enable option definition from argument.yaml.
  • Remove OpsiSeaMiles_Enable field from GeneratedConfig, including its default value.
  • Remove OpsiSeaMiles from the Opsi task group in task.yaml so it is no longer exposed as a separate task/section.
  • Clean up related config templates, args JSON, and i18n entries so there are no dangling references to OpsiSeaMiles.
module/config/argument/argument.yaml
module/config/config_generated.py
module/config/argument/task.yaml
config/template.json
module/config/argument/args.json
module/config/i18n/en-US.json
module/config/i18n/ja-JP.json
module/config/i18n/zh-CN.json
module/config/i18n/zh-MIAO.json
module/config/i18n/zh-TW.json

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我在这里给出了一些整体层面的反馈:

  • 由于 OpsiSeaMiles 配置组和 OpsiSeaMiles_Enable 标志已被移除,请再次检查并清理对这些字段的任何剩余引用(包括通过动态属性访问的引用),以避免出现意料之外的 AttributeError 或遗留的死代码路径。
给 AI 代理的提示
Please address the comments from this code review:

## Overall Comments
- Since the OpsiSeaMiles config group and `OpsiSeaMiles_Enable` flag are removed, please double-check and clean up any remaining references to these fields (including dynamic attribute access) to avoid unexpected `AttributeError` or dead code paths.

Sourcery 对开源项目是免费的——如果你觉得我们的评论有帮助,请考虑分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的代码审查。
Original comment in English

Hey - I've left some high level feedback:

  • Since the OpsiSeaMiles config group and OpsiSeaMiles_Enable flag are removed, please double-check and clean up any remaining references to these fields (including dynamic attribute access) to avoid unexpected AttributeError or dead code paths.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Since the OpsiSeaMiles config group and `OpsiSeaMiles_Enable` flag are removed, please double-check and clean up any remaining references to these fields (including dynamic attribute access) to avoid unexpected `AttributeError` or dead code paths.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a 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 removes the OpsiSeaMiles configuration toggle from all configuration and localization files, making the sea miles detection feature automatic. In the code, the detection logic is now executed unconditionally. The reviewer suggested improving the logging strategy by using logger.info instead of logger.warning for expected detection failures and using logger.exception to capture full stack traces during errors.

Comment on lines +510 to +518
logger.info("开始海里数检测")
try:
sea_miles = self.detect_and_record_sea_miles()
if sea_miles is not None:
logger.info(f"海里数检测完成: {sea_miles}")
else:
logger.warning("海里数检测失败,但不影响后续流程")
except Exception as e:
logger.error(f"海里数检测异常: {e},但不影响后续流程")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

既然海里数检测现在已改为自动执行且不影响后续流程,建议优化日志级别以减少对用户的干扰。特别是当检测失败(返回 None)时,这通常是因为不在正确的界面,使用 logger.warning 可能会让用户误以为发生了严重问题。建议将其降级为 logger.info。此外,对于异常捕获,建议使用 logger.exception 以便记录完整的堆栈信息,方便排查问题。

Suggested change
logger.info("开始海里数检测")
try:
sea_miles = self.detect_and_record_sea_miles()
if sea_miles is not None:
logger.info(f"海里数检测完成: {sea_miles}")
else:
logger.warning("海里数检测失败,但不影响后续流程")
except Exception as e:
logger.error(f"海里数检测异常: {e},但不影响后续流程")
logger.info("开始海里数检测")
try:
sea_miles = self.detect_and_record_sea_miles()
if sea_miles is not None:
logger.info(f"海里数检测完成: {sea_miles}")
else:
logger.info("海里数检测失败,但不影响后续流程")
except Exception:
logger.exception("海里数检测异常,但不影响后续流程")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant