drop() leaves the jobs table behind, and a table re-declared under the same name inherits it

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

维护者通常 6 天内回复

@dimitri-yatsenko 已经在做这个了。

开始于 2026年10月17日。

  • #1615 来自 @dimitri-yatsenko —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
mysql, python

调研方向

Start with table.py:1224 (drop_quick) and the lazy jobs-table creation in autopopulate.py:182-188. Trace how AutoPopulate.jobs validates and uses the jobs table, then update the drop behavior and add the primary-key compatibility check. The issue is done when dropping a table also removes its jobs table and an existing mismatched jobs table raises an error.

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

描述

bug

Summary

drop() removes an auto-populated table but not its jobs table, ~~<table_name>. drop_quick() (table.py:1224) drops only full_table_name. The jobs table is created lazily by AutoPopulate.jobs (autopopulate.py:182-188), and nothing else removes it, so it stays, with its records and its primary key.

When a table is later declared under the same name, its jobs property picks up the old jobs table. If the new table's primary key differs, populate(reserve_jobs=True) computes nothing and raises no error. refresh() adds key_source - target - jobs, and the old records, keyed on part of the new primary key, cover every new key.

Reproduction

DataJoint 2.3.5.dev8 (master, a00b89f5), MySQL 8.0.46, Python 3.11:

import datajoint as dj

schema = dj.Schema("scratch_drop_jobs")

@schema
class Item(dj.Manual):
    definition = """
    item : int32
    """

@schema
class Param(dj.Lookup):
    definition = """
    param : int32
    """
    contents = [(1,), (2,)]

@schema
class Result(dj.Computed):
    definition = """
    -> Item
    ---
    value : int32
    """

    def make(self, key):
        raise RuntimeError("not ready")

Item.insert({"item": i} for i in range(3))
Result.populate(reserve_jobs=True, suppress_errors=True)
Result.drop(prompt=False)
print("tables after drop:", [r[0] for r in schema.connection.query("SHOW TABLES FROM `scratch_drop_jobs`")])

@schema
class Result(dj.Computed):  # same name, primary key now includes Param
    definition = """
    -> Item
    -> Param
    ---
    value : int32
    """

    def make(self, key):
        self.insert1(dict(key, value=1))

print("jobs primary key:", Result.jobs.heading.primary_key, "records:", [j["status"] for j in Result.jobs.to_dicts()])
Result.populate(reserve_jobs=True)
print("rows after populate(reserve_jobs=True):", len(Result()), "of", len(Result.key_source))

Output:

tables after drop: ['#param', 'item', '~lineage', '~~result']
jobs primary key: ['item'] records: ['error', 'error', 'error']
rows after populate(reserve_jobs=True): 0 of 6

Expected behavior

  • drop() drops each table's jobs table along with the table, as it already removes the table's ~lineage entries.
  • AutoPopulate.jobs checks that an existing jobs table's primary key matches the table's, and raises if it does not. That also catches jobs tables left behind by earlier releases.
主要语言
Python
星标
198
派生
103
平均合并
6 天 1 小时
30 天内合并 PR
10

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

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

datajoint/datajoint-python 的其他 Issue

查看 datajoint/datajoint-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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