@@ -121,6 +121,17 @@ def check_job_dependencies_scheduled(
121121 )
122122 dep_ivl = f"[{ dep_start } , { dep_stop } )"
123123
124+ # Cache schedule enumeration of dependents, as they are probably evaluated
125+ # many times.
126+ dep_insts = {}
127+ def get_dep_insts (job ):
128+ try :
129+ return dep_insts [job .job_id ]
130+ except KeyError :
131+ insts = list (get_insts_to_schedule (job , dep_start , dep_stop ))
132+ dep_insts [job .job_id ] = insts
133+ return insts
134+
124135 for schedule in job .schedules :
125136 # Construct all instances that will be scheduled soon.
126137 insts = get_insts_to_schedule (job , sched_start , sched_stop )
@@ -132,15 +143,12 @@ def check_job_dependencies_scheduled(
132143 # Bind the dependency to get the precise args that match.
133144 dep = dep .bind (run , jobs )
134145
135- # Look at cheduled runs of the dependency job in `dep_times.
136- # Check if any matches the dependency args.
146+ # Look at scheduled runs of the dependency job. Check if any
147+ # matches the dependency args.
137148 dep_job = jobs_dir .get_job (dep .job_id )
138149 if not any (
139150 i .args == dep .args
140- for _ , i in get_insts_to_schedule (
141- dep_job ,
142- dep_start , dep_stop
143- )
151+ for _ , i in get_dep_insts (dep_job )
144152 ):
145153 # No matches.
146154 dep_inst = Instance (dep .job_id , dep .args )
0 commit comments