diff --git a/crc/__init__.py b/crc/__init__.py index 2f90bbf1..f856ff33 100644 --- a/crc/__init__.py +++ b/crc/__init__.py @@ -132,7 +132,7 @@ def validate_all(study_id, category=None, spec_id=None): study = session.query(StudyModel).filter(StudyModel.id == study_id).first() g.user = session.query(UserModel).filter(UserModel.uid == study.user_uid).first() g.token = "anything_is_fine_just_need_something." - specs = WorkflowSpecService.get_specs() + specs = WorkflowSpecService().get_specs() for spec in specs: if spec_id and spec_id != spec.id: continue @@ -145,11 +145,11 @@ def validate_all(study_id, category=None, spec_id=None): print(f"Skipping {spec.id} in category {spec.category.display_name}, it is disabled for this study.") else: print(f"API Error {e.code}, validate workflow {spec.id} in Category {spec.category.display_name}") - return + continue except WorkflowTaskExecException as e: print(f"Workflow Error, {e}, in Task {e.task.name} validate workflow {spec.id} in Category {spec.category.display_name}") - return + continue except Exception as e: - print(f"Unexpected Error, {e} validate workflow {spec.id} in Category {spec.category.display_name}") + print(f"Unexpected Error ({e.__class__.__name__}), {e} validate workflow {spec.id} in Category {spec.category.display_name}") print(e) - return + continue diff --git a/crc/services/lookup_service.py b/crc/services/lookup_service.py index c28ed611..defe3a03 100644 --- a/crc/services/lookup_service.py +++ b/crc/services/lookup_service.py @@ -1,4 +1,5 @@ import logging +import math import re from collections import OrderedDict from zipfile import BadZipFile @@ -83,7 +84,10 @@ class LookupService(object): # to rebuild. workflow_spec = WorkflowSpecService().get_spec(workflow.workflow_spec_id) timestamp = SpecFileService.timestamp(workflow_spec, lookup_model.file_name) - is_current = timestamp == lookup_model.file_timestamp + print(f"*** Comparing {timestamp} and {lookup_model.file_timestamp}") + # Assures we have the same timestamp, as storage in the database might create slight variations in + # the floating point values, just assure they values match to within a second. + is_current = int(timestamp - lookup_model.file_timestamp) == 0 if not is_current: # Very very very expensive, but we don't know need this till we do. diff --git a/tests/test_lookup_service.py b/tests/test_lookup_service.py index 30ece256..78440892 100644 --- a/tests/test_lookup_service.py +++ b/tests/test_lookup_service.py @@ -1,4 +1,5 @@ import os +from time import sleep from tests.base_test import BaseTest @@ -30,7 +31,9 @@ class TestLookupService(BaseTest): lookup_table_orig = session.query(LookupFileModel).first() LookupService.lookup(workflow, "Task_Enum_Lookup", "sponsor", "something", limit=10) lookup_table = session.query(LookupFileModel).first() - self.assertEqual(lookup_table_orig, lookup_table) + self.assertEqual(lookup_table_orig, lookup_table, f"Lookup models should be the same, and have the same dates:" + f"{lookup_table_orig.file_timestamp} " + f"and {lookup_table.file_timestamp} ") LookupService.lookup(workflow, "Task_Enum_Lookup", "sponsor", "blah", limit=10) lookup_records = session.query(LookupFileModel).all() self.assertIsNotNone(lookup_records) @@ -50,6 +53,7 @@ class TestLookupService(BaseTest): lookup_data = session.query(LookupDataModel).filter(LookupDataModel.lookup_file_model == lookup_record).all() self.assertEqual(28, len(lookup_data)) + sleep(1) # Update the workflow specification file. file_path = os.path.join(app.root_path, '..', 'tests', 'data', 'enum_options_with_search', 'sponsors_modified.xlsx')