Skip to content

Commit 9d3a9e4

Browse files
committed
chore: remove the optional purge_jobs in schedule_jobs
1 parent 7184ce5 commit 9d3a9e4

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

datajoint/autopopulate.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ def jobs(self):
528528
return self._Jobs & {"table_name": self.target.table_name}
529529

530530
def schedule_jobs(
531-
self, *restrictions, purge_jobs=False, min_scheduling_interval=None
531+
self, *restrictions, min_scheduling_interval=None
532532
):
533533
"""
534534
Schedule new jobs for this autopopulate table by finding keys that need computation.
@@ -538,12 +538,8 @@ def schedule_jobs(
538538
2. If recent scheduling event exists, skips scheduling to prevent database load
539539
3. Otherwise, finds keys that need computation and schedules them
540540
541-
The method also optionally purges invalid jobs (jobs that no longer exist in key_source)
542-
to maintain database cleanliness.
543-
544541
Args:
545542
restrictions: a list of restrictions each restrict (table.key_source - target.proj())
546-
purge_jobs: if True, remove orphaned jobs from the jobs table (potentially expensive operation)
547543
min_scheduling_interval: minimum time in seconds that must have passed since last job scheduling.
548544
If None, uses the value from dj.config["min_scheduling_interval"] (default: None)
549545
@@ -589,11 +585,8 @@ def schedule_jobs(
589585
logger.info(
590586
f"{schedule_count} new jobs scheduled for `{to_camel_case(self.target.table_name)}`"
591587
)
592-
finally:
593-
if purge_jobs:
594-
self.purge_jobs()
595588

596-
def purge_jobs(self):
589+
def cleanup_jobs(self):
597590
"""
598591
Check and remove any orphaned/outdated jobs in the JobTable for this autopopulate table.
599592

docs/jobs_orchestration.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ The `populate()` method orchestrates the job execution process:
7777
- Records errors and execution metrics
7878

7979
4. **Cleanup**:
80-
- Optionally purges orphaned/outdated jobs
80+
- Optionally clean up orphaned/outdated jobs
8181

8282
## Job Cleanup Process
8383

84-
The `purge_jobs` method maintains database consistency by removing orphaned jobs:
84+
The `cleanup_jobs` method maintains database consistency by removing orphaned jobs:
8585

8686
1. **Orphaned Success Jobs**:
8787
- Identifies jobs marked as `success` but not present in the target table
@@ -107,7 +107,7 @@ The "freshness" and consistency of the jobs table depends on regular maintenance
107107
- Example: Run every few minutes in a cron job for active pipelines
108108
- Event-driven approach: `inserts` in upstream tables auto trigger this step
109109

110-
2. **Cleanup** (`purge_jobs`):
110+
2. **Cleanup** (`cleanup_jobs`):
111111
- Removes orphaned or outdated jobs
112112
- Should be run periodically to maintain consistency
113113
- More resource-intensive than scheduling
@@ -129,5 +129,5 @@ dj.config["min_scheduling_interval"] = 300 # 5 minutes
129129
# (implement as a cron job or scheduled task)
130130
def daily_cleanup():
131131
for table in your_pipeline_tables:
132-
table.purge_jobs()
132+
table.cleanup_jobs()
133133
```

0 commit comments

Comments
 (0)