Skip to content

Commit 0f98b18

Browse files
committed
Remove legacy schema-wide jobs system
Replace schema-wide `~jobs` table with per-table JobsTable (Autopopulate 2.0): - Delete src/datajoint/jobs.py (old JobTable class) - Remove legacy_jobs property from Schema class - Delete tests/test_jobs.py (old schema-wide tests) - Remove clean_jobs fixture and schema.jobs.delete() cleanup calls - Update test_autopopulate.py to use new per-table jobs API The new system provides per-table job queues with FK-derived primary keys, rich status tracking (pending/reserved/success/error/ignore), priority scheduling, and proper handling of job collisions.
1 parent e89e064 commit 0f98b18

5 files changed

Lines changed: 8 additions & 336 deletions

File tree

src/datajoint/jobs.py

Lines changed: 0 additions & 154 deletions
This file was deleted.

src/datajoint/schemas.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from .errors import AccessError, DataJointError
1111
from .external import ExternalMapping
1212
from .heading import Heading
13-
from .jobs import JobTable
1413
from .settings import config
1514
from .table import FreeTable, Log, lookup_class_name
1615
from .user_tables import Computed, Imported, Lookup, Manual, Part, _get_tier
@@ -70,7 +69,6 @@ def __init__(
7069
self.context = context
7170
self.create_schema = create_schema
7271
self.create_tables = create_tables
73-
self._jobs = None
7472
self._auto_populated_tables = [] # Track auto-populated table classes
7573
self.external = ExternalMapping(self)
7674
self.add_objects = add_objects
@@ -354,21 +352,6 @@ def jobs(self):
354352
self._assert_exists()
355353
return [table_class().jobs for table_class in self._auto_populated_tables]
356354

357-
@property
358-
def legacy_jobs(self):
359-
"""
360-
Access the legacy schema-level job reservation table (~jobs).
361-
362-
This is provided for backward compatibility and migration purposes.
363-
New code should use per-table jobs via `MyTable.jobs` or `schema.jobs`.
364-
365-
:return: legacy JobTable
366-
"""
367-
self._assert_exists()
368-
if self._jobs is None:
369-
self._jobs = JobTable(self.connection, self.database)
370-
return self._jobs
371-
372355
@property
373356
def code(self):
374357
self._assert_exists()

tests/conftest.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import datajoint as dj
1818
from datajoint.errors import (
1919
FILEPATH_FEATURE_SWITCH,
20-
DataJointError,
2120
)
2221

2322
from . import schema, schema_advanced, schema_external, schema_object, schema_simple
@@ -55,21 +54,6 @@ def clean_autopopulate(experiment, trial, ephys):
5554
experiment.delete()
5655

5756

58-
@pytest.fixture
59-
def clean_jobs(schema_any):
60-
"""
61-
Explicit cleanup fixture for jobs tests.
62-
63-
Cleans jobs table before test runs.
64-
Tests must explicitly request this fixture to get cleanup.
65-
"""
66-
try:
67-
schema_any.jobs.delete()
68-
except DataJointError:
69-
pass
70-
yield
71-
72-
7357
@pytest.fixture
7458
def clean_test_tables(test, test_extra, test_no_extra):
7559
"""
@@ -569,10 +553,6 @@ def mock_cache(tmpdir_factory):
569553
def schema_any(connection_test, prefix):
570554
schema_any = dj.Schema(prefix + "_test1", schema.LOCALS_ANY, connection=connection_test)
571555
assert schema.LOCALS_ANY, "LOCALS_ANY is empty"
572-
try:
573-
schema_any.jobs.delete()
574-
except DataJointError:
575-
pass
576556
schema_any(schema.TTest)
577557
schema_any(schema.TTest2)
578558
schema_any(schema.TTest3)
@@ -612,10 +592,6 @@ def schema_any(connection_test, prefix):
612592
schema_any(schema.Stimulus)
613593
schema_any(schema.Longblob)
614594
yield schema_any
615-
try:
616-
schema_any.jobs.delete()
617-
except DataJointError:
618-
pass
619595
schema_any.drop()
620596

621597

@@ -624,10 +600,6 @@ def schema_any_fresh(connection_test, prefix):
624600
"""Function-scoped schema_any for tests that need fresh schema state."""
625601
schema_any = dj.Schema(prefix + "_test1_fresh", schema.LOCALS_ANY, connection=connection_test)
626602
assert schema.LOCALS_ANY, "LOCALS_ANY is empty"
627-
try:
628-
schema_any.jobs.delete()
629-
except DataJointError:
630-
pass
631603
schema_any(schema.TTest)
632604
schema_any(schema.TTest2)
633605
schema_any(schema.TTest3)
@@ -667,10 +639,6 @@ def schema_any_fresh(connection_test, prefix):
667639
schema_any(schema.Stimulus)
668640
schema_any(schema.Longblob)
669641
yield schema_any
670-
try:
671-
schema_any.jobs.delete()
672-
except DataJointError:
673-
pass
674642
schema_any.drop()
675643

676644

tests/test_autopopulate.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,22 @@ def test_populate_key_list(clean_autopopulate, subject, experiment, trial):
6161
assert n == ret["success_count"]
6262

6363

64-
def test_populate_exclude_error_and_ignore_jobs(clean_autopopulate, schema_any, subject, experiment):
64+
def test_populate_exclude_error_and_ignore_jobs(clean_autopopulate, subject, experiment):
6565
# test simple populate
6666
assert subject, "root tables are empty"
6767
assert not experiment, "table already filled?"
6868

69+
# Ensure jobs table is set up by refreshing
70+
jobs = experiment.jobs
71+
jobs.refresh()
72+
6973
keys = experiment.key_source.fetch("KEY", limit=2)
7074
for idx, key in enumerate(keys):
7175
if idx == 0:
72-
schema_any.jobs.ignore(experiment.table_name, key)
76+
jobs.ignore(key)
7377
else:
74-
schema_any.jobs.error(experiment.table_name, key, "")
78+
jobs.reserve(key)
79+
jobs.error(key, error_message="Test error")
7580

7681
experiment.populate(reserve_jobs=True)
7782
assert len(experiment.key_source & experiment) == len(experiment.key_source) - 2

0 commit comments

Comments
 (0)