Skip to content

Commit

Permalink
Change pendulum.Period to pendulum.Interval
Browse files Browse the repository at this point in the history
breaking change in pendulum v3
see python-pendulum/pendulum#676
  • Loading branch information
na399 authored Dec 23, 2023
1 parent ada9407 commit f589f71
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get_execution_period_for_policy(
freshness_policy: FreshnessPolicy,
effective_data_time: Optional[datetime.datetime],
current_time: datetime.datetime,
) -> pendulum.Period:
) -> pendulum.Interval:
if freshness_policy.cron_schedule:
tick_iterator = cron_string_iterator(
start_timestamp=current_time.timestamp(),
Expand All @@ -42,18 +42,18 @@ def get_execution_period_for_policy(
tick = next(tick_iterator)
required_data_time = tick - freshness_policy.maximum_lag_delta
if effective_data_time is None or effective_data_time < required_data_time:
return pendulum.Period(start=required_data_time, end=tick)
return pendulum.Interval(start=required_data_time, end=tick)

else:
# occurs when asset is missing
if effective_data_time is None:
return pendulum.Period(
return pendulum.Interval(
# require data from at most maximum_lag_delta ago
start=current_time - freshness_policy.maximum_lag_delta,
# this data should be available as soon as possible
end=current_time,
)
return pendulum.Period(
return pendulum.Interval(
# we don't want to execute this too frequently
start=effective_data_time + 0.9 * freshness_policy.maximum_lag_delta,
end=max(effective_data_time + freshness_policy.maximum_lag_delta, current_time),
Expand All @@ -65,7 +65,7 @@ def get_execution_period_and_evaluation_data_for_policies(
policies: AbstractSet[FreshnessPolicy],
effective_data_time: Optional[datetime.datetime],
current_time: datetime.datetime,
) -> Tuple[Optional[pendulum.Period], Optional["TextRuleEvaluationData"]]:
) -> Tuple[Optional[pendulum.Interval], Optional["TextRuleEvaluationData"]]:
"""Determines a range of times for which you can kick off an execution of this asset to solve
the most pressing constraint, alongside a maximum number of additional constraints.
"""
Expand All @@ -85,7 +85,7 @@ def get_execution_period_and_evaluation_data_for_policies(
if merged_period is None:
merged_period = period
elif period.start <= merged_period.end:
merged_period = pendulum.Period(
merged_period = pendulum.Interval(
start=max(period.start, merged_period.start),
end=period.end,
)
Expand Down

0 comments on commit f589f71

Please sign in to comment.