From aa69f1e8dff30000fe8d9e1fdd62ad7b3e586ff7 Mon Sep 17 00:00:00 2001 From: Dhanur Sharma Date: Fri, 21 Mar 2025 16:39:36 -0500 Subject: [PATCH] Added objects for weekend schedule --- inference/models/inference.py | 2 -- inference/signals.py | 16 ++++++++++++++++ inference/tasks.py | 4 ---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/inference/models/inference.py b/inference/models/inference.py index 60732cc7..29778e9c 100644 --- a/inference/models/inference.py +++ b/inference/models/inference.py @@ -301,7 +301,6 @@ def refresh_status_and_store_results(self) -> None: """Process this external job and update status/results""" try: api_client = InferenceAPIClient() - # model_version = ModelVersion.objects.get(classification_type=self.inference_job.classification_type) model_version = self.inference_job.model_version response = api_client.get_job_status(model_version.api_identifier, self.external_job_id) @@ -314,7 +313,6 @@ def refresh_status_and_store_results(self) -> None: # Handle completion or failure if new_status == ExternalJobStatus.COMPLETED: self.store_results(response.get("results")) - # self.completed_at = timezone.now() # completed in mark_completed called in store_results self.save() except Exception as e: diff --git a/inference/signals.py b/inference/signals.py index 70d0dd39..d662ff16 100644 --- a/inference/signals.py +++ b/inference/signals.py @@ -22,3 +22,19 @@ def create_periodic_tasks(sender, **kwargs): name="Process inference queue (6pm-7am)", task="inference.tasks.process_inference_job_queue", ) + + # Create schedule the weekend + weekend_crontab, _ = CrontabSchedule.objects.get_or_create( + minute="*/5", + hour="*", + day_of_week="0,6", + day_of_month="*", + month_of_year="*", + ) + + # Create the periodic task if it doesn't exist + PeriodicTask.objects.get_or_create( + crontab=weekend_crontab, + name="Process inference queue (Weekends)", + task="inference.tasks.process_inference_job_queue", + ) diff --git a/inference/tasks.py b/inference/tasks.py index f6afab05..cba5b43f 100644 --- a/inference/tasks.py +++ b/inference/tasks.py @@ -18,10 +18,6 @@ def process_inference_job_queue(): return "Queue processing already in progress" try: - # Reevaluate progress and update status of all inference jobs that are not currently queued - # for job in InferenceJob.objects.exclude(status=InferenceJobStatus.QUEUED): - # job.reevaluate_progress_and_update_status() - # Look for pending jobs first pending_jobs = InferenceJob.objects.filter(status=InferenceJobStatus.PENDING)