From ba51dd93e08d0894a75e97bc40f3709a2be21442 Mon Sep 17 00:00:00 2001 From: ponyisi Date: Wed, 25 Sep 2024 12:47:23 -0500 Subject: [PATCH] Fix pending lookup issue #854 (#855) * Fix pending lookup issue #854 --- .../servicex_app/resources/internal/fileset_complete.py | 4 +++- .../resources/internal/test_fileset_complete.py | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/servicex_app/servicex_app/resources/internal/fileset_complete.py b/servicex_app/servicex_app/resources/internal/fileset_complete.py index 5d99053e..576c5f93 100644 --- a/servicex_app/servicex_app/resources/internal/fileset_complete.py +++ b/servicex_app/servicex_app/resources/internal/fileset_complete.py @@ -28,6 +28,7 @@ from flask import request, current_app from servicex_app.models import Dataset, db, TransformRequest, TransformStatus, DatasetStatus +from servicex_app.dataset_manager import DatasetManager from servicex_app.resources.servicex_resource import ServiceXResource @@ -54,8 +55,9 @@ def put(self, dataset_id): if summary['files'] > 0: # Now time to pick up any transform requests for this dataset that came in # while we were still looking up files and send the dataset to them + dataset_manager = DatasetManager(dataset, current_app.logger, db) for transform_request in TransformRequest.lookup_pending_on_dataset(int(dataset_id)): - dataset.publish_files(transform_request, self.lookup_result_processor) + dataset_manager.publish_files(transform_request, self.lookup_result_processor) transform_request.status = TransformStatus.running # also resolve the status of whatever transform prompted this lookup diff --git a/servicex_app/servicex_app_test/resources/internal/test_fileset_complete.py b/servicex_app/servicex_app_test/resources/internal/test_fileset_complete.py index 58a7fe92..d03e5eeb 100644 --- a/servicex_app/servicex_app_test/resources/internal/test_fileset_complete.py +++ b/servicex_app/servicex_app_test/resources/internal/test_fileset_complete.py @@ -28,6 +28,7 @@ from datetime import timezone, datetime from servicex_app import LookupResultProcessor, TransformerManager +from servicex_app.dataset_manager import DatasetManager from servicex_app_test.resource_test_base import ResourceTestBase from servicex_app.models import DatasetStatus, Dataset, TransformRequest, TransformStatus @@ -65,6 +66,8 @@ def test_put_fileset_complete(self, mocker, mock_find_dataset_by_id): return_value=[lookup_request]) mock_processor = mocker.MagicMock(LookupResultProcessor) + mock_publish_files = mocker.patch.object(DatasetManager, "publish_files") + client = self._test_client(lookup_result_processor=mock_processor) response = client.put('/servicex/internal/transformation/1234/complete', @@ -83,7 +86,7 @@ def test_put_fileset_complete(self, mocker, mock_find_dataset_by_id): mock_lookup_pending.assert_called_once_with(1234) mock_lookup_running.assert_called_once_with(1234) - dataset.publish_files.assert_called_once_with(pending_request, mock_processor) + mock_publish_files.assert_called_once_with(pending_request, mock_processor) assert pending_request.status == TransformStatus.running assert lookup_request.status == TransformStatus.running