diff --git a/atdb/taskdatabase/models.py b/atdb/taskdatabase/models.py index 24254a155ef9b322b8c47d9ec5e30cee1265c85b..a289b34c9326c011703d073aa5b81648a3cbeafb 100644 --- a/atdb/taskdatabase/models.py +++ b/atdb/taskdatabase/models.py @@ -110,7 +110,7 @@ class Activity(models.Model): def __str__(self): return str(self.sas_id) - def create_storage_location(self, task): + def create_storage_location(self): workdir = Configuration.objects.get(key='executor:workdir').value self.storage_location = workdir.replace('run', 'aggregate') + str(self.sas_id) diff --git a/atdb/taskdatabase/services/activities_handler.py b/atdb/taskdatabase/services/activities_handler.py index eadd462ff3d86ca742128d9c585e5f23186b0835..45cfd5d6d816271b3fe0d9fd3a2d53aab7f2ed22 100644 --- a/atdb/taskdatabase/services/activities_handler.py +++ b/atdb/taskdatabase/services/activities_handler.py @@ -202,6 +202,11 @@ def update_processed_and_aggregate(task): if (task.workflow.aggregation_strategy == AggregationStrategy.COLLECT_H5.value): + # check if there is already a storage_location, if not, add it. + if not activity.storage_location: + # for this aggregation_strategy, the activity storage_location is the workdir of the aggregation task + activity.create_storage_location() + # check if the activity is ready to collect H5 data if (not activity.is_aggregated and activity.status != State.COLLECTING_DATA.value and @@ -215,11 +220,6 @@ def update_processed_and_aggregate(task): else: aggregation_task = aggregation_tasks[0] - # check if there is already a storage_location, if not, add it. - if not activity.storage_location: - # for this aggregation_strategy, the activity storage_location is the workdir of the aggregation task - activity.create_storage_location() - # this means that its tasks know that they should copy their H5 files to the storage_location # (but the tasks cannot do that, the aggregator service does) activity.status = State.COLLECTING_DATA.value diff --git a/atdb/taskdatabase/tests/test_update_activity.py b/atdb/taskdatabase/tests/test_update_activity.py index 4a13870029f263dafd7e99471d59c6e7ae429f70..364f1036649393295b067a4b30d0a95a01a58d1d 100644 --- a/atdb/taskdatabase/tests/test_update_activity.py +++ b/atdb/taskdatabase/tests/test_update_activity.py @@ -216,4 +216,4 @@ class TestUpdateActivity(TestCase): expected = "/project/ldv/Share/aggregate/113" actual = self.task11.activity.storage_location - #self.assertEqual(actual, expected) + self.assertEqual(actual, expected)