Skip to content

Wrap the local time of day in the baseline schedule policy into 0 to 24 hours - #205

Open
burgulvedant wants to merge 1 commit into
google:copybara_pushfrom
burgulvedant:fix-schedule-local-time
Open

burgulvedant wants to merge 1 commit into
google:copybara_pushfrom
burgulvedant:fix-schedule-local-time

Conversation

@burgulvedant

Copy link
Copy Markdown

Fixes #201

The baseline SchedulePolicy builds its lookup time as Timedelta(hod) + local_start_time.utcoffset(), where hod is the UTC hour of day. At UTC-7 the UTC hours 0 to 6 give a negative time. No schedule event starts before 0, so get_active_setpoint falls back to the last event of the day, the 19:00 night setpoint. For two hours every evening (17:00 to 19:00 Pacific) the schedule uses night setpoints while the comfort window is still active.

This adds a small helper, local_schedule_time, that wraps the sum into 0 to 24 hours, and uses it in SchedulePolicy._get_action_map.

I added schedule_policy_test.py with 8 tests: the wrap itself (negative offset, no wrap, local midnight, positive offset) and the day and night setpoint at UTC hours 0, 1, 2, 6, 7, 13 and 23 at UTC-7. Three of them fail without the wrap.

Not covered here: the offset is read once from the start time, so daylight saving changes during a run are not handled. That is a separate issue.

How I tested: I could not install the full TensorFlow 2.15 environment on my machine (Python 3.14), so I ran the new tests locally with the tf_agents and tensorflow imports stubbed out. They pass. The full pytest run on Python 3.10 and 3.11 will be done by CI.

  • Tests pass (8 new tests pass locally with stubbed imports, full run pending CI)
  • Appropriate changes to documentation are included in the PR (none needed, the new function has a docstring)

@burgulvedant

Copy link
Copy Markdown
Author

CI note: the failing check on this PR does not come from the change. The test (ubuntu-latest, 3.10.15) job fails at setup because Python 3.10.15 is not available on the Ubuntu 26.04 runner that ubuntu-latest now points to. The other three matrix jobs were then cancelled by the matrix fail fast. No tests ran, so the 8 new tests in schedule_policy_test.py have not been checked by CI yet. Happy to rebase or adjust once the workflow is fixed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Baseline SchedulePolicy day/night switches early vs SB1 local comfort window (UTC hod + utcoffset)

1 participant