Skip to content

Commit 2fa57ef

Browse files
committed
draft: some more unit test updates (working up to process_pipeline_request)
1 parent e550531 commit 2fa57ef

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

ami/jobs/tests.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
import logging
33
import time
44

5+
from django.db import connection
6+
57
# import pytest
6-
from django.test import TestCase
8+
from django.test import TestCase, TransactionTestCase
79
from guardian.shortcuts import assign_perm
810
from rest_framework.test import APIRequestFactory, APITestCase
911

@@ -210,7 +212,7 @@ def test_cancel_job(self):
210212
pass
211213

212214

213-
class TestMLJobBatchProcessing(TestCase):
215+
class TestMLJobBatchProcessing(TransactionTestCase):
214216
def setUp(self):
215217
self.project = Project.objects.first() # get the original test project
216218
assert self.project
@@ -382,9 +384,11 @@ def get_ml_subtask_details(task_name, job):
382384
return details
383385

384386
job.run()
387+
connection.commit()
388+
job.refresh_from_db()
385389

386390
start_time = time.time()
387-
timeout = 10 # seconds
391+
timeout = 30 # seconds
388392
elapsed_time = 0
389393

390394
while elapsed_time < timeout:

ami/ml/models/pipeline.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ def collect_images(
164164
def process_pipeline_request(pipeline_request: dict, project_id: int):
165165
# TODO: instead of dict can we use pipeline request object?
166166
"""
167-
Placeholder for the processing service's request processing logic
167+
This is the primary function for processing images on the antenna side.
168+
Workers have a function of the same name which will run their own inference/processing logic.
169+
On the antenna side, we use external servers via an API to process images.
168170
"""
169171
request_data = PipelineRequest(**pipeline_request)
170172
source_image_requests = request_data.source_images

ami/ml/tasks.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,4 @@ def check_ml_job_status(ml_job_id: int):
137137
from django.db import transaction
138138

139139
logger.info(f"ML Job {ml_job_id} still in progress. Checking again for completed tasks.")
140-
transaction.on_commit(
141-
lambda: check_ml_job_status.apply_async([ml_job_id], countdown=10)
142-
) # check again in 10 seconds
140+
transaction.on_commit(lambda: check_ml_job_status.apply_async([ml_job_id])) # check again in 10 seconds

0 commit comments

Comments
 (0)