Skip to content
Snippets Groups Projects
Commit 5c73dc07 authored by Nico Vermaas's avatar Nico Vermaas
Browse files

handling review comments

parent 3cb16acd
Branches
No related tags found
1 merge request!350SDC-1313 ancillary dataproducts to dcache (ATDB side)
Pipeline #79200 passed
Showing
with 32 additions and 37 deletions
REM dump the configuration table as a json file (fixture)
python manage.py dumpdata taskdatabase.configuration --indent 4 --settings=atdb.settings.dev > configuration_fixture.json python manage.py dumpdata taskdatabase.configuration --indent 4 --settings=atdb.settings.dev > configuration_fixture.json
REM sdc-dev / sdc REM sdc-dev / sdc
......
REM dump the workflows tables as a json file (fixture)
python manage.py dumpdata taskdatabase.workflow --indent 4 --settings=atdb.settings.dev > workflow_fixture.json python manage.py dumpdata taskdatabase.workflow --indent 4 --settings=atdb.settings.dev > workflow_fixture.json
REM sdc-dev / sdc REM sdc-dev / sdc
......
REM load the configuration_fixture.json from a json file
python manage.py loaddata configuration_fixture.json --settings=atdb.settings.dev python manage.py loaddata configuration_fixture.json --settings=atdb.settings.dev
REM sdc-dev / sdc REM sdc-dev / sdc
......
REM load the workflows table from a json file (fixture)
python manage.py loaddata workflow_fixture.json --settings=atdb.settings.dev python manage.py loaddata workflow_fixture.json --settings=atdb.settings.dev
REM sdc-dev / sdc REM sdc-dev / sdc
......
REM create the database migration file (this does not do the actual migration, see migration.bat for that)
python manage.py makemigrations --settings=atdb.settings.dev python manage.py makemigrations --settings=atdb.settings.dev
REM don't forget to add the new migration file to the repo (right click on the migration file, choose git -> add). REM don't forget to add the new migration file to the repo (right click on the migration file, choose git -> add).
\ No newline at end of file
REM run the database migration
python manage.py migrate --settings=atdb.settings.dev python manage.py migrate --settings=atdb.settings.dev
\ No newline at end of file
astronauth==0.3.3 astronauth==0.3.3
Django==5 Django==5
django-allauth==0.57.0 # note allauth only supports Django >= 3.2 django-allauth==0.57.0 # note allauth only supports Django >= 3.2
#django-bootstrap-pagination==1.7.1
django-bootstrap3==23.6 django-bootstrap3==23.6
django-cors-headers==3.6.0 django-cors-headers==3.6.0
django-extensions==3.1.0 django-extensions==3.1.0
......
REM example of how to rollback a database change
python manage.py migrate taskdatabase 0010 --settings=atdb.settings.dev python manage.py migrate taskdatabase 0010 --settings=atdb.settings.dev
\ No newline at end of file
REM add a superuser to the database
python manage.py createsuperuser --settings=atdb.settings.dev python manage.py createsuperuser --settings=atdb.settings.dev
\ No newline at end of file
...@@ -208,14 +208,8 @@ class Task(models.Model): ...@@ -208,14 +208,8 @@ class Task(models.Model):
return str(self.id) + ' - (' + self.task_type + ') - ' + str(self.sas_id) return str(self.id) + ' - (' + self.task_type + ') - ' + str(self.sas_id)
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
# nv:1mar2023, temporary hack, set tasks 'on hold' as soon they get to 'scrubbed'
# (users forget to do that manually, causing unwanted ingests)
# nv:8apr2024, SDO asked for this hack to be removed again. # calculate the qualities for this task
# if (self.status != State.SCRUBBED.value) & (self.new_status == State.SCRUBBED.value):
# self.resume = False
# nv:19jun2023, calculate the qualities for this task
if (self.status != State.STORED.value) & (self.new_status == State.STORED.value): if (self.status != State.STORED.value) & (self.new_status == State.STORED.value):
# read the quality_thresholds from the Configuration table # read the quality_thresholds from the Configuration table
...@@ -245,11 +239,6 @@ class Task(models.Model): ...@@ -245,11 +239,6 @@ class Task(models.Model):
# if so, temporarily put it on hold so that the ancillary service can grab it with it # if so, temporarily put it on hold so that the ancillary service can grab it with it
if self.is_summary: if self.is_summary:
# slightly bothered by the idea that ATDB puts it on HOLD and depends on the ancillary service
# to resume it. But users have earlier asked for the same dynamic for scrubbed. Acceptable
# TODO: (un)comment this
# We don't want ATDB holding tasks without a aggregator service in place to resume
self.resume = False self.resume = False
except Exception as error: except Exception as error:
......
...@@ -79,6 +79,7 @@ def update_activity(task): ...@@ -79,6 +79,7 @@ def update_activity(task):
- to STORED : calculate quality - to STORED : calculate quality
- to SCRUBBED, ARCHIVING, ARCHIVED, FINISHED : calculate ingested_fraction - to SCRUBBED, ARCHIVING, ARCHIVED, FINISHED : calculate ingested_fraction
- to _FAILED : calculate finished_fraction - to _FAILED : calculate finished_fraction
- to STORED, PROCESSED, DISCARDED : check if all tasks are processed, set Activity to is_processed and AGGREGATE
- always : determine if a task is in a 'verified' status - always : determine if a task is in a 'verified' status
""" """
......
...@@ -32,14 +32,14 @@ class TestProcessedSummary(TestCase): ...@@ -32,14 +32,14 @@ class TestProcessedSummary(TestCase):
actual = self.task1.resume actual = self.task1.resume
self.assertEqual(actual, True) self.assertEqual(actual, True)
# def test_processed_on_hold(self): def test_processed_on_hold(self):
# """ """
# task 2 is processed, and a summary dataproduct. Should go on hold task 2 is processed, and a summary dataproduct. Should go on hold
# """ """
#
# actual = self.task2.resume actual = self.task2.resume
# # this test fails, because "self.resume = False" is still commented out in models.py L249 # this test fails, because "self.resume = False" is still commented out in models.py L249
# self.assertEqual(actual, False) self.assertEqual(actual, False)
def test_activity_is_processed(self): def test_activity_is_processed(self):
""" """
......
...@@ -29,39 +29,34 @@ class TestSummaryTasks(TestCase): ...@@ -29,39 +29,34 @@ class TestSummaryTasks(TestCase):
""" """
test task that is not a summary task test task that is not a summary task
""" """
actual = self.no_summary_task_77777.is_summary self.assertFalse(self.no_summary_task_77777.is_summary)
self.assertEqual(actual, False)
def test_task_defined_does_not_know_that_it_is_summary(self): def test_task_defined_does_not_know_that_it_is_summary(self):
""" """
test summary task, but before it knows that it becomes a summary task (which it only knows when 'processed') test summary task, but before it knows that it becomes a summary task (which it only knows when 'processed')
""" """
actual = self.summary_task_defined_77777.is_summary self.assertFalse(self.summary_task_defined_77777.is_summary)
self.assertEqual(actual, False)
def test_task_validated_knows_that_it_is_summary(self): def test_task_validated_knows_that_it_is_summary(self):
""" """
test summary task, at 'stored' it should know that it is a summary task and return True) test summary task, at 'stored' it should know that it is a summary task and return True)
""" """
self.summary_task_validated_77777.save() self.summary_task_validated_77777.save()
actual = self.summary_task_validated_77777.is_summary self.assertTrue(self.summary_task_validated_77777.is_summary)
self.assertEqual(actual, True)
def test_task_processed_knows_that_it_is_summary(self): def test_task_processed_knows_that_it_is_summary(self):
""" """
test summary task, at 'stored' it should know that it is a summary task and return True) test summary task, at 'stored' it should know that it is a summary task and return True)
""" """
self.summary_task_processed_77777.save() self.summary_task_processed_77777.save()
actual = bool(self.summary_task_processed_77777.is_summary) self.assertTrue(self.summary_task_processed_77777.is_summary)
self.assertEqual(actual, True)
def test_summary_task_processed_goes_on_halt(self): def test_summary_task_processed_goes_on_halt(self):
""" """
test summary task, at 'stored' it should know that it is a summary task and return True) test summary task, at 'stored' it should know that it is a summary task and return True)
""" """
self.summary_task_processed_88888.save() self.summary_task_processed_88888.save()
actual = self.summary_task_processed_88888.resume self.assertFalse(self.summary_task_processed_88888.resume)
self.assertEqual(actual, False)
def test_activity_77777_not_is_processed(self): def test_activity_77777_not_is_processed(self):
""" """
...@@ -69,8 +64,7 @@ class TestSummaryTasks(TestCase): ...@@ -69,8 +64,7 @@ class TestSummaryTasks(TestCase):
""" """
self.summary_task_processed_77777.save() self.summary_task_processed_77777.save()
activity = self.summary_task_processed_77777.activity activity = self.summary_task_processed_77777.activity
actual = bool(activity.is_processed) self.assertFalse(activity.is_processed)
self.assertFalse(actual)
def test_activity_88888_is_processed(self): def test_activity_88888_is_processed(self):
""" """
...@@ -79,5 +73,4 @@ class TestSummaryTasks(TestCase): ...@@ -79,5 +73,4 @@ class TestSummaryTasks(TestCase):
self.summary_task_stored_88888.save() self.summary_task_stored_88888.save()
self.summary_task_processed_88888.save() self.summary_task_processed_88888.save()
activity = self.summary_task_processed_88888.activity activity = self.summary_task_processed_88888.activity
actual = activity.is_processed self.assertTrue(activity.is_processed)
self.assertTrue(actual) \ No newline at end of file
\ No newline at end of file
...@@ -188,7 +188,7 @@ class TestUpdateActivity(TestCase): ...@@ -188,7 +188,7 @@ class TestUpdateActivity(TestCase):
def test_is_processed(self): def test_is_processed(self):
""" """
task 6, 7 and 8 are processed, task 6, 7 and 8 are processed,
activity.is_processed should be true and activity status should go to 'handle_ancillary' activity.is_processed should be true and activity status should go to 'aggregate'
""" """
activity = self.task6.activity activity = self.task6.activity
......
REM test a single unittest
python manage.py test taskdatabase.tests.test_update_activity.TestUpdateActivity --settings=atdb.settings.dev python manage.py test taskdatabase.tests.test_update_activity.TestUpdateActivity --settings=atdb.settings.dev
\ No newline at end of file
REM runs the unit tests for ATDB
python manage.py test --settings=atdb.settings.dev python manage.py test --settings=atdb.settings.dev
\ No newline at end of file
python manage.py test --settings atdb.settings.test_local
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment