An Imported `_x` and a Computed `__x` in one schema share the jobs table `~~x`

オープン
#1,740 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 5 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
18/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
python
領域
databases

調査の方向性

Start from the reproduction script: declare the Imported _result and Computed __result, then compare computed.jobs.full_table_name and imported.jobs.full_table_name. Read the jobs-table naming and refresh()/populate(reserve_jobs=True) paths, plus PR #1615 for the existing shared-table checks. Done means a chosen disambiguation policy, with tests proving the two job queues no longer mix records.

索引モデルが issue の本文から書いたものです。

説明

bug

Summary

The jobs table of a Computed or Imported table is named ~~ followed by the table name without its leading underscores. An Imported class Result (table _result) and a Computed class Result (table __result) can be declared in the same schema, and both map to the jobs table ~~result. A jobs table's rows hold the primary key and the job state, not the table they belong to, so the two tables share one job queue without any sign of it.

Effects

  • Same primary key. Each table reads and changes the other's job records. refresh() adds a pending job only for a key that has no job record, so a key with an error, ignore or reserved record from one table gets no job for the other, and populate(reserve_jobs=True) on the other table skips it. Either table's populate(reserve_jobs=True) also reserves pending jobs that the other table's refresh() added. Each table's refresh() judges every record against its own key_source, so it can remove the other table's records.
  • Different primary keys. The jobs table has the key of whichever table declared it first. With https://github.com/datajoint/datajoint-python/pull/1615, the other table's jobs raises an error that names both tables; before it, the other table used a jobs table keyed on the wrong attributes.
  • Dropping one of the two. With https://github.com/datajoint/datajoint-python/pull/1615, drop() keeps the shared jobs table, with a warning, while the other table exists, and drops it with the second table. Without that check, dropping either table would drop the other's job records too.

A Manual result also maps to ~~result, but a Manual table has no jobs table, so it does not conflict.

Reproduction

import datajoint as dj

schema = dj.Schema("scratch_jobs_names")

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

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

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

computed = Result

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

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

imported = Result

Item.insert({"item": i} for i in range(3))
computed.populate(reserve_jobs=True, suppress_errors=True)
print(computed.jobs.full_table_name, imported.jobs.full_table_name)  # the same table
imported.populate(reserve_jobs=True)
print(len(imported()))  # 0: the Computed table's error records block every key

Options

  • Name the jobs table after the full table name (~~_result and ~~__result). Existing jobs tables would need to be renamed, or dropped and rebuilt by refresh(), which loses their error and ignore records.
  • Refuse to declare a Computed __x while an Imported _x exists in the same schema, and the reverse.
  • Record the owning table in each job record. This keeps one jobs table per name but changes the jobs table's primary key.
主要言語
Python
スター
198
フォーク
107
平均マージ
4日 7時間
マージ済み PR(30日)
12

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

datajoint/datajoint-python のほかの issue

datajoint/datajoint-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。