Skip to content

Commit

Permalink
Include daytime in daily schedule expansion.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexhsamuel committed Jan 28, 2022
1 parent 31d19cc commit ede616c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
17 changes: 17 additions & 0 deletions jobs/test/schedule/daily.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
params: [date, time, daytime]

program:
type: shell
command: |
date
echo date={{ date }}
echo time={{ time }}
echo daytime={{ daytime }}
schedule:
type: daily
calendar: all
daytime: [19:18:00]
tz: UTC
cal_shift: 1

15 changes: 10 additions & 5 deletions python/apsis/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import ora
from ora import Daytime, Time, TimeZone

from .lib.exc import SchemaError
from .lib.json import TypedJso, check_schema
from .lib.py import format_ctor

Expand Down Expand Up @@ -89,17 +88,23 @@ def __call__(self, start: Time):
while True:
sched_date = self.calendar.shift(date, self.cal_shift)
sched_date = sched_date + self.date_shift
daytime = self.daytimes[i]
try:
time = (sched_date, self.daytimes[i]) @ self.tz
time = (sched_date, daytime) @ self.tz
except ora.NonexistentDateDaytime:
# Landed in a DST transition.
log.warning(
"skipping nonexistent schedule time "
f"{sched_date} {self.daytimes[i]} {self.tz}"
f"{sched_date} {daytime} {self.tz}"
)
continue
assert time >= start
args = {"date": str(date), "time": time, **common_args}
args = {
"date": str(date),
"time": time,
"daytime": str(daytime),
**common_args,
}
yield time, args

i += 1
Expand Down Expand Up @@ -135,7 +140,7 @@ def from_jso(cls, jso):
date_shift = pop("date_shift", int, default=0)
cal_shift = pop("cal_shift", int, default=0)
return cls(
tz, calendar, daytimes, args,
tz, calendar, daytimes, args,
enabled=enabled, date_shift=date_shift, cal_shift=cal_shift,
)

Expand Down

0 comments on commit ede616c

Please sign in to comment.