Skip to content

Commit

Permalink
fix simulation model testing
Browse files Browse the repository at this point in the history
  • Loading branch information
TShapinsky committed Jan 8, 2025
1 parent 5c792ff commit 8cd08ad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion alfalfa_worker/jobs/step_run_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def exec(self) -> None:
self.logger.info("Done initializing simulation")
self.set_run_status(RunStatus.STARTED)
self.advance_to_start_time()
if self.options.warmup_is_first_step:
if self.options.warmup_is_first_step and self.options.clock_source == ClockSource.INTERNAL:
self.advance()
self.set_run_status(RunStatus.RUNNING)
self.logger.info(f"Clock source: {self.options.clock_source}")
Expand Down
9 changes: 5 additions & 4 deletions tests/jobs/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import pytest

from alfalfa_worker.jobs.step_run_base import ClockSource
from alfalfa_worker.lib.enums import RunStatus, SimType
from alfalfa_worker.lib.job import JobStatus
from tests.worker.lib.mock_dispatcher import MockDispatcher
Expand Down Expand Up @@ -33,14 +34,14 @@ def test_simple_internal_clock(mock_dispatcher: MockDispatcher, model_path: Path
"start_datetime": str(datetime.datetime(2019, 1, 2, 0, 0, 0)),
"end_datetime": str(datetime.datetime(2019, 1, 3, 0, 0, 0)),
"timescale": "5",
"realtime": None
"realtime": False
}

if run.sim_type == SimType.OPENSTUDIO:
step_run_job = mock_dispatcher.start_job("alfalfa_worker.jobs.openstudio.step_run.StepRun", params)
else:
step_run_job = mock_dispatcher.start_job("alfalfa_worker.jobs.modelica.step_run.StepRun", params)
assert step_run_job.step_sim_type == "timescale"
assert step_run_job.options.clock_source == ClockSource.INTERNAL
run = step_run_job.run
wait_for_job_status(step_run_job, JobStatus.RUNNING)
wait_for_run_status(run, RunStatus.RUNNING)
Expand Down Expand Up @@ -68,7 +69,7 @@ def test_simple_external_clock(mock_dispatcher: MockDispatcher, model_path: Path
"start_datetime": str(start_dt),
"end_datetime": str(datetime.datetime(2019, 1, 3, 0, 0, 0)),
"timescale": "1",
"realtime": None
"realtime": False
}

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

wait_for_run_status(run, RunStatus.RUNNING, timeout=30)
wait_for_run_status(run, RunStatus.RUNNING, timeout=60)
wait_for_job_status(step_run_job, JobStatus.WAITING)

# -- Assert model gets to expected start time
Expand Down

0 comments on commit 8cd08ad

Please sign in to comment.