-
Notifications
You must be signed in to change notification settings - Fork 1
refactor: query auth use CredentialInput instead of str #437
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 by CodeRabbit
Walkthrough本次变更将 CredentialInput 类型从 executor 本地实现迁移到 oocana 包内统一定义与导出,并相应调整导入与 API 签名:Context.query_auth 改为接收 CredentialInput 对象,executor 侧改为从 oocana 引用该类型。新增 oocana/oocana/credential.py 文件并在包 init 中公开导出。 Changes
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: 返回
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Pre-merge checks❌ Failed checks (1 inconclusive)
✅ Passed checks (1 passed)
Comment |
90423c8
to
53885e4
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: 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: stroocana/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
📒 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
同时包含type
和id
两个属性。请确认后端是否需要凭证类型信息。如果需要,应将其添加到请求载荷中。
如果需要发送凭证类型,应用以下改动:
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
)与构造函数签名一致。重构成功实现了类型定义的集中管理。
No description provided.