diff --git a/skydriver/rest_handlers.py b/skydriver/rest_handlers.py index 18360535..a93b3fb3 100644 --- a/skydriver/rest_handlers.py +++ b/skydriver/rest_handlers.py @@ -1051,7 +1051,7 @@ async def get(self, scan_id: str) -> None: LOGGER.exception(e) # scan state - scan_state = await get_scan_state(manifest, self.ewms_rc) + scan_state = await get_scan_state(manifest, self.ewms_rc, self.results) # ewms if ( diff --git a/skydriver/utils.py b/skydriver/utils.py index 31a74dee..7ba5a083 100644 --- a/skydriver/utils.py +++ b/skydriver/utils.py @@ -4,7 +4,7 @@ from rest_tools.client import RestClient -from . import ewms +from . import database, ewms from .database.schema import DEPRECATED_EWMS_TASK, Manifest, PENDING_EWMS_WORKFLOW @@ -12,6 +12,9 @@ class _ScanState(enum.Enum): """A non-persisted scan state.""" SCAN_FINISHED_SUCCESSFULLY = enum.auto() + # ^^^ indicates the scanner sent finished results. in reality, the scanner or ewms + # could've crashed immediately after BUT the user only cares about the RESULTS--so, + # this would still be considered a SUCCESS in *this* context IN_PROGRESS__PARTIAL_RESULT_GENERATED = enum.auto() IN_PROGRESS__WAITING_ON_FIRST_PIXEL_RECO = enum.auto() @@ -19,9 +22,14 @@ class _ScanState(enum.Enum): PENDING__PRESTARTUP = enum.auto() -async def get_scan_state(manifest: Manifest, ewms_rc: RestClient) -> str: +async def get_scan_state( + manifest: Manifest, + ewms_rc: RestClient, + results: database.interface.ResultClient, +) -> str: """Determine the state of the scan by parsing attributes and talking with EWMS.""" - if manifest.progress and manifest.progress.processing_stats.finished: + if (await results.get(manifest.scan_id)).is_final: + # NOTE: see note on 'SCAN_FINISHED_SUCCESSFULLY' above return _ScanState.SCAN_FINISHED_SUCCESSFULLY.name def _has_cleared_backlog() -> bool: diff --git a/tests/integration/dummy_ewms.py b/tests/integration/dummy_ewms.py index 89d6983d..cf5a8a6b 100644 --- a/tests/integration/dummy_ewms.py +++ b/tests/integration/dummy_ewms.py @@ -62,7 +62,7 @@ def dummy_query_taskforces(): resp = { "taskforces": [ { - "taskforce_uuid": f"TF-{workflow_id}", + "taskforce_uuid": f"TF-{workflow_id['workflow_id']}", "phase": "the-best-phase-ever", } ]