Skip to content

Conversation

leavesster
Copy link
Contributor

No description provided.

Copy link

coderabbitai bot commented Oct 10, 2025

Summary by CodeRabbit

  • 新功能
    • 新增 CredentialInput 类型并作为公共导出,可直接在应用中创建与传递凭据输入。
  • 重构
    • 认证查询接口改为接收 CredentialInput,而非纯字符串 ID,参数更一致、可读性更好。
    • 需要将调用处更新为传入 CredentialInput 实例;其余凭据处理行为保持不变。

Walkthrough

本次变更将 CredentialInput 类型从 executor 本地实现迁移到 oocana 包内统一定义与导出,并相应调整导入与 API 签名:Context.query_auth 改为接收 CredentialInput 对象,executor 侧改为从 oocana 引用该类型。新增 oocana/oocana/credential.py 文件并在包 init 中公开导出。

Changes

Cohort / File(s) Change Summary
提取并公开 CredentialInput 类型
oocana/oocana/credential.py, oocana/oocana/__init__.py
新增 CredentialInput 类(包含 type、id 字段);在包入口增加 CredentialInput 的公开导出。
上下文认证接口签名调整
oocana/oocana/context.py
Context.query_auth 参数从 id: str 改为 credential: CredentialInput;请求体改用 credential.id;新增相应导入。
执行器侧类型来源切换
executor/python_executor/credential.py
移除本地定义的 CredentialInput,改为从 oocana 导入并沿用原有使用逻辑。

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Caller as 调用方
  participant Exec as Executor(credential.py)
  participant Ctx as oocana.Context
  participant Auth as Auth Service

  Caller->>Exec: 生成 CredentialInput(type, id)
  Exec->>Ctx: query_auth(credential: CredentialInput)
  Ctx->>Auth: POST /auth { id: credential.id, type: credential.type }
  Auth-->>Ctx: 响应(认证结果)
  Ctx-->>Exec: 返回认证结果
  Exec-->>Caller: 返回
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • refactor: use three component #434: 同样围绕 CredentialInput 的结构与解析调整(value → id、三段式解析),与本次将类型集中到 oocana 并改用对象传递直接相关。
  • feat: support credential input #433: 引入并在执行器中使用 CredentialInput 的前置改动,与本次将该类型迁移到 oocana 并统一导出的变更直接相关。

Pre-merge checks

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description Check ❓ Inconclusive 作者未提供任何 PR 描述,当前描述为空且无法反映改动细节或意图,因此过于笼统。 请在 PR 描述中补充简要的变更说明,以便审阅者了解本次重构的背景、目的和影响。
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed 标题采用了 <type>: <subject> 的约定格式,使用全英文并准确地描述了将 query_auth 方法改为接受 CredentialInput 而非字符串的重构意图,符合规范要求。

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a 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

🧹 Nitpick comments (2)
oocana/oocana/credential.py (1)

1-4: 建议为属性添加类型注解。

当前实现缺少属性的类型注解,这会降低 IDE 的类型推断和代码补全能力。建议添加类型注解以提升代码质量。

应用以下改动添加类型注解:

 class CredentialInput:
+    type: str
+    id: str
+    
     def __init__(self, type: str, id: str):
         self.type = type
         self.id = id

可选方案:使用 dataclass 简化代码。

如果项目支持 Python 3.7+,建议使用 dataclass 装饰器来简化代码并自动生成 __init____repr__ 等方法:

from dataclasses import dataclass

@dataclass
class CredentialInput:
    """Credential input data holder."""
    type: str
    id: str
oocana/oocana/__init__.py (1)

9-9: 移除不必要的 noqa 指令。

根据静态分析工具 Ruff 的提示,第 9 行的 # noqa: F403 指令是不必要的,因为这一行使用的是显式导入而非通配符导入。

应用以下改动移除不必要的 noqa 指令:

-from .serialization import setup_dataframe_serialization, CompressionOptions  # noqa: F403
+from .serialization import setup_dataframe_serialization, CompressionOptions
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 020b540 and 53885e4.

📒 Files selected for processing (4)
  • executor/python_executor/credential.py (1 hunks)
  • oocana/oocana/__init__.py (1 hunks)
  • oocana/oocana/context.py (3 hunks)
  • oocana/oocana/credential.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
executor/python_executor/credential.py (1)
oocana/oocana/credential.py (1)
  • CredentialInput (1-4)
oocana/oocana/context.py (1)
oocana/oocana/credential.py (1)
  • CredentialInput (1-4)
oocana/oocana/__init__.py (2)
oocana/oocana/serialization.py (2)
  • setup_dataframe_serialization (23-50)
  • CompressionOptions (8-17)
oocana/oocana/credential.py (1)
  • CredentialInput (1-4)
🪛 Ruff (0.13.3)
oocana/oocana/__init__.py

9-9: Unused noqa directive (unused: F403)

Remove unused noqa directive

(RUF100)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: check
  • GitHub Check: check
🔇 Additional comments (5)
oocana/oocana/__init__.py (1)

10-10: LGTM!

CredentialInput 的导出正确,使其在包命名空间中可用。

oocana/oocana/context.py (2)

14-14: LGTM!

CredentialInput 的导入正确且符合新的类型定义。


684-709: 验证请求载荷是否应包含凭证类型。

方法签名更新正确,现在接收 CredentialInput 对象而非字符串 ID。但是,请注意第 703 行的请求载荷只发送了 credential.id,而 CredentialInput 同时包含 typeid 两个属性。

请确认后端是否需要凭证类型信息。如果需要,应将其添加到请求载荷中。

如果需要发送凭证类型,应用以下改动:

 self.__mainframe.send(self.job_info, {
     "type": "BlockRequest",
     "action": "QueryAuth",
     "id": credential.id,
+    "credential_type": credential.type,
     "session_id": self.session_id,
     "job_id": self.job_id,
     "request_id": request_id,
 })
executor/python_executor/credential.py (2)

2-2: LGTM!

oocana 包导入 CredentialInput 的改动正确,成功消除了代码重复,将类型定义统一到 oocana 包中。


5-27: LGTM!

generate_credential_input 函数正确使用了来自 oocana 的 CredentialInput 类,参数顺序(type, id)与构造函数签名一致。重构成功实现了类型定义的集中管理。

@leavesster leavesster enabled auto-merge (squash) October 10, 2025 04:54
@leavesster leavesster merged commit 7d95acc into main Oct 10, 2025
8 checks passed
@leavesster leavesster deleted the credential branch October 10, 2025 04:55
@oomol-bot oomol-bot mentioned this pull request Oct 10, 2025
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