@@ -136,6 +136,50 @@ def _should_add_local_src(candidate: Path) -> bool:
136136 "probe_time" : "CLOUD_SCHEDULER_PROBE_TIME" ,
137137 "precheck_time" : "CLOUD_SCHEDULER_PRECHECK_TIME" ,
138138}
139+ WEEKDAY_CRON_DAYS = frozenset ({1 , 2 , 3 , 4 , 5 })
140+ CRON_DAY_NAMES = {
141+ "SUN" : 0 ,
142+ "MON" : 1 ,
143+ "TUE" : 2 ,
144+ "WED" : 3 ,
145+ "THU" : 4 ,
146+ "FRI" : 5 ,
147+ "SAT" : 6 ,
148+ }
149+
150+
151+ def _cron_day_value (raw : str ) -> int :
152+ value = raw .strip ().upper ()
153+ if value in CRON_DAY_NAMES :
154+ return CRON_DAY_NAMES [value ]
155+ numeric = int (value )
156+ if not 0 <= numeric <= 7 :
157+ raise ValueError (f"Invalid cron day-of-week value: { raw !r} " )
158+ return numeric % 7
159+
160+
161+ def _cron_days_of_week (raw : str ) -> set [int ]:
162+ days : set [int ] = set ()
163+ for item in raw .split ("," ):
164+ base , separator , raw_step = item .strip ().partition ("/" )
165+ step = int (raw_step ) if separator else 1
166+ if step <= 0 :
167+ raise ValueError (f"Invalid cron day-of-week step: { item !r} " )
168+ if base == "*" :
169+ values = list (range (7 ))
170+ elif "-" in base :
171+ raw_start , raw_end = base .split ("-" , 1 )
172+ start = _cron_day_value (raw_start )
173+ end = _cron_day_value (raw_end )
174+ values = [start ]
175+ while values [- 1 ] != end :
176+ values .append ((values [- 1 ] + 1 ) % 7 )
177+ if len (values ) > 7 :
178+ raise ValueError (f"Invalid cron day-of-week range: { item !r} " )
179+ else :
180+ values = [_cron_day_value (base )]
181+ days .update (values [::step ])
182+ return days
139183
140184# Strategy-derived vars: auto-populated from platform-config.json defaults.
141185def _derive_strategy_env_defaults (strategy_config : dict ) -> dict [str , str ]:
@@ -512,7 +556,11 @@ def _build_scheduler_plan(
512556 if len (fields ) == 2 :
513557 scheduler [key ] = " " .join ([* fields , "*" , "*" , "1-5" ])
514558 fields = scheduler [key ].split ()
515- if len (fields ) != 5 or fields [2 :] != ["*" , "*" , "1-5" ]:
559+ try :
560+ scheduled_days = _cron_days_of_week (fields [4 ]) if len (fields ) == 5 else set ()
561+ except (TypeError , ValueError ):
562+ scheduled_days = set ()
563+ if len (fields ) != 5 or fields [2 ] != "*" or not scheduled_days or not scheduled_days <= WEEKDAY_CRON_DAYS :
516564 raise ValueError (
517565 f"US live account scheduler { key } must be Mon-Fri cron: { scheduler [key ]!r} "
518566 )
0 commit comments