ProjectTech4DevAI / ProjectTech4DevAI/kaapi-backend

Async Job: Foreign Key Association for Project and Organization

未关闭
#552 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Python
星标
18
派生
10
平均合并
2 天 20 小时
30 天内合并 PR
14

描述

Describe the current behavior
Async "Job" database model does not have project_id and organization_id FK relation

Describe the enhancement you'd like
Add these relations or use batch_job table for both the celery async job and other batch job status

Why is this enhancement needed?
From a maintainability perspective

Additional context

class Job(SQLModel, table=True):
    """Database model for tracking async jobs."""

    __tablename__ = "job"

    id: UUID = Field(
        default_factory=uuid4,
        primary_key=True,
        sa_column_kwargs={"comment": "Unique identifier for the job"},
    )
    task_id: str | None = Field(
        nullable=True,
        description="Celery task ID returned when job is queued.",
        sa_column_kwargs={"comment": "Celery task ID returned when job is queued"},
    )
    trace_id: str | None = Field(
        default=None,
        description="Tracing ID for correlating logs and traces.",
        sa_column_kwargs={"comment": "Tracing ID for correlating logs and traces"},
    )
    error_message: str | None = Field(
        default=None,
        description="Error details if the job fails.",
        sa_column_kwargs={"comment": "Error details if the job fails"},
    )
    status: JobStatus = Field(
        default=JobStatus.PENDING,
        description="Current state of the job.",
        sa_column_kwargs={
            "comment": "Current state of the job (PENDING, PROCESSING, SUCCESS, FAILED)"
        },
    )
    job_type: JobType = Field(
        description="Type of job being executed (e.g., response, ingestion).",
        sa_column_kwargs={
            "comment": "Type of job being executed (e.g., RESPONSE, LLM_API)"
        },
    )

    # Timestamps
    created_at: datetime = Field(
        default_factory=now,
        sa_column_kwargs={"comment": "Timestamp when the job was created"},
    )
    updated_at: datetime = Field(
        default_factory=now,
        sa_column_kwargs={"comment": "Timestamp when the job was last updated"},
    )

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先定位 SQLModel 的 Job 定义以及现有的 projectorganizationbatch_job 模型或表。比较异步作业应接收两个外键关系,还是应共享 batch_job,然后检查相关的 schema 和 migration 约定。完成的标准是,所选设计能够维护所需的关联,同时不重复作业状态模型。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
backend, databases
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。