Repository navigation
Open
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behavior
Milestone
Description
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 anerror,ignoreorreservedrecord from one table gets no job for the other, andpopulate(reserve_jobs=True)on the other table skips it. Either table'spopulate(reserve_jobs=True)also reserves pending jobs that the other table'srefresh()added. Each table'srefresh()judges every record against its ownkey_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 fix(drop): drop an auto-populated table's jobs table with it #1615, the other table's
jobsraises 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 fix(drop): drop an auto-populated table's jobs table with it #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 keyOptions
- Name the jobs table after the full table name (
~~_resultand~~__result). Existing jobs tables would need to be renamed, or dropped and rebuilt byrefresh(), which loses theirerrorandignorerecords. - Refuse to declare a Computed
__xwhile an Imported_xexists 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.
Metadata
Metadata
Assignees
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behavior
Activity