Skip to content

Commit 8cd08ad

Browse files
committed
fix simulation model testing
1 parent 5c792ff commit 8cd08ad

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

alfalfa_worker/jobs/step_run_base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def exec(self) -> None:
106106
self.logger.info("Done initializing simulation")
107107
self.set_run_status(RunStatus.STARTED)
108108
self.advance_to_start_time()
109-
if self.options.warmup_is_first_step:
109+
if self.options.warmup_is_first_step and self.options.clock_source == ClockSource.INTERNAL:
110110
self.advance()
111111
self.set_run_status(RunStatus.RUNNING)
112112
self.logger.info(f"Clock source: {self.options.clock_source}")

tests/jobs/test_workflow.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import pytest
55

6+
from alfalfa_worker.jobs.step_run_base import ClockSource
67
from alfalfa_worker.lib.enums import RunStatus, SimType
78
from alfalfa_worker.lib.job import JobStatus
89
from tests.worker.lib.mock_dispatcher import MockDispatcher
@@ -33,14 +34,14 @@ def test_simple_internal_clock(mock_dispatcher: MockDispatcher, model_path: Path
3334
"start_datetime": str(datetime.datetime(2019, 1, 2, 0, 0, 0)),
3435
"end_datetime": str(datetime.datetime(2019, 1, 3, 0, 0, 0)),
3536
"timescale": "5",
36-
"realtime": None
37+
"realtime": False
3738
}
3839

3940
if run.sim_type == SimType.OPENSTUDIO:
4041
step_run_job = mock_dispatcher.start_job("alfalfa_worker.jobs.openstudio.step_run.StepRun", params)
4142
else:
4243
step_run_job = mock_dispatcher.start_job("alfalfa_worker.jobs.modelica.step_run.StepRun", params)
43-
assert step_run_job.step_sim_type == "timescale"
44+
assert step_run_job.options.clock_source == ClockSource.INTERNAL
4445
run = step_run_job.run
4546
wait_for_job_status(step_run_job, JobStatus.RUNNING)
4647
wait_for_run_status(run, RunStatus.RUNNING)
@@ -68,7 +69,7 @@ def test_simple_external_clock(mock_dispatcher: MockDispatcher, model_path: Path
6869
"start_datetime": str(start_dt),
6970
"end_datetime": str(datetime.datetime(2019, 1, 3, 0, 0, 0)),
7071
"timescale": "1",
71-
"realtime": None
72+
"realtime": False
7273
}
7374

7475
if run.sim_type == SimType.OPENSTUDIO:
@@ -77,7 +78,7 @@ def test_simple_external_clock(mock_dispatcher: MockDispatcher, model_path: Path
7778
step_run_job = mock_dispatcher.start_job("alfalfa_worker.jobs.modelica.step_run.StepRun", params)
7879
run = step_run_job.run
7980

80-
wait_for_run_status(run, RunStatus.RUNNING, timeout=30)
81+
wait_for_run_status(run, RunStatus.RUNNING, timeout=60)
8182
wait_for_job_status(step_run_job, JobStatus.WAITING)
8283

8384
# -- Assert model gets to expected start time

0 commit comments

Comments
 (0)