Add scheduling API conveniences: callable-tolerant rule properties, every-N-days, IANA time zone ids, default time rule - #9677
Draft
jhonabreul wants to merge 1 commit into
Conversation
- FuncTimeRule/FuncDateRule define __call__ returning the rule itself, so Python calls like self.time_rules.midnight() or self.date_rules.today() no longer fail with "'FuncTimeRule' object is not callable" - DateRules.Every(TimeSpan): every-N-days date rule anchored at the start of the schedule, accepting a timedelta in Python - TimeRules.At overloads accepting an IANA time zone id string, e.g. at(8, 0, 0, "Europe/London") - ScheduleManager.On(dateRule, callback): defaults the time rule to midnight in the algorithm time zone, mirroring universe selection schedules; the PyObject overload rejects a time rule or non-callable in the callback slot with an explicit error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Scheduling API conveniences addressing recurring crash shapes:
self.time_rules.midnight(),noon(),now(),self.date_rules.today(),tomorrow()return the rule instead of failing with'FuncTimeRule' object is not callable.DateRules.Every(TimeSpan): every-N-days rule, anchored at the schedule start (date_rules.every(timedelta(days=5))). Rejects sub-day or fractional-day intervals, pointing atTimeRules.Every().TimeRules.At(hour, minute[, second], "Europe/London"): accepts an IANA time zone id where aDateTimeZonewas required, with a clear error for unknown ids.Schedule.On(dateRule, callback): defaults the time rule to midnight, mirroring universe selection schedules. A time rule (or any non-callable) in the callback slot fails with an explicit "missing callback" error instead of silently scheduling a no-op.Deferred:
DateRules.Every(int)(ambiguous with theEvery(DayOfWeek)binding), aminutes=kwarg alias onafter_market_open(breaking rename), andZoneInfoarguments inAt()(the string form covers the usage).Related Issue
N/A
Motivation and Context
Scheduling is one of the most universal APIs, and these exact call shapes are recurring runtime crashes: properties and methods are indistinguishable to Python callers, and the two-argument universe-selection
schedule.on(date_rule)teaches a two-argument form that didn't exist.Requires Documentation Change
The new overloads could be added to the scheduled events documentation.
How Has This Been Tested?
TimeRulesTests/DateRulesTests: string time zone equivalence and invalid-id error, every-N-days anchoring and interval validation, Pythontimedeltacreation, property-call tolerance from Python.ScheduleManagerTests: midnight default (C# and Python callbacks), missing-callback and non-callable guards.SchedulingConvenienceRegressionAlgorithm(C# + Python): asserts exact fire times for the new rules; the Python twin exercises the property-call tolerance. Both pass.Types of changes
Checklist:
bug-<issue#>-<description>orfeature-<issue#>-<description>