Skip to content

Commit

Permalink
Address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyestein committed Oct 8, 2024
1 parent fd9d987 commit b7819da
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 21 deletions.
7 changes: 4 additions & 3 deletions emap-setup/emap_runner/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,9 @@ def docker(self) -> None:

def validation(self) -> ValidationRunner:
"""Run a validation run of EMAP"""
# allow for hoover not to be defined in global config
use_hoover = ("hoover" in self.global_config["repositories"]) and self.args.use_hoover
# user should explicitly switch off hoover if not defined in global config
if self.args.use_hoover and "hoover" not in self.global_config["repositories"]:
raise ValueError("hoover requested but is missing from repositories in global config")

runner = ValidationRunner(
docker_runner=DockerRunner(project_dir=Path.cwd(), config=self.global_config),
Expand All @@ -209,7 +210,7 @@ def validation(self) -> ValidationRunner:
),
should_build=not self.args.skip_build,
use_hl7_reader=self.args.use_hl7_reader,
use_hoover=use_hoover,
use_hoover=self.args.use_hoover,
use_waveform=self.args.use_waveform,
)
runner.run()
Expand Down
25 changes: 7 additions & 18 deletions emap-setup/emap_runner/validation/validation_runner.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from subprocess import Popen
from datetime import date, timedelta
from time import time, sleep
import time
from typing import Union, List
from pathlib import Path

Expand Down Expand Up @@ -29,7 +29,6 @@ def __init__(
self.use_hoover = use_hoover
self.use_waveform = use_waveform

self.start_time = None
self.timeout = timedelta(hours=10)

self.docker = docker_runner
Expand Down Expand Up @@ -174,33 +173,23 @@ def _wait_for_queue_to_empty(self) -> None:
If it's still going after 10 hours something's gone very wrong and we
should give up
"""
self.start_time = time()
start_time_monotonic = time.monotonic()

while self._has_populated_queues:

sleep(120)

if self._exceeded_timeout:
time.sleep(120)
elapsed_time = timedelta(seconds=time.monotonic() - start_time_monotonic)
if elapsed_time > self.timeout:
self._save_logs_and_stop()
raise ValidationRunnerException(
f"Waiting for queue timed out. Elapsed time "
f"({self._elapsed_time}) > timeout ({self.timeout})"
f"({elapsed_time}) > timeout ({self.timeout})"
)

# exits too keenly from databaseExtracts queue, adding in a wait period
sleep(600)
time.sleep(600)

return None

@property
def _exceeded_timeout(self) -> bool:
return self._elapsed_time > self.timeout

@property
def _elapsed_time(self) -> timedelta:
"""Time elapsed since the runner started"""
return timedelta(seconds=time() - self.start_time)

@property
def _has_populated_queues(self) -> bool:
"""Are there queues that are still populated?
Expand Down

0 comments on commit b7819da

Please sign in to comment.