Skip to content

Commit

Permalink
change SCAN_FINISHED_SUCCESSFULLY to be "got final result"
Browse files Browse the repository at this point in the history
  • Loading branch information
ric-evans committed Jan 28, 2025
1 parent 296ffe9 commit 2dcf30c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion skydriver/rest_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
14 changes: 11 additions & 3 deletions skydriver/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,32 @@

from rest_tools.client import RestClient

from . import ewms
from . import database, ewms
from .database.schema import DEPRECATED_EWMS_TASK, Manifest, PENDING_EWMS_WORKFLOW


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()
PENDING__WAITING_ON_SCANNER_SERVER_STARTUP = enum.auto()
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:
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/dummy_ewms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
]
Expand Down

0 comments on commit 2dcf30c

Please sign in to comment.