@@ -116,9 +116,6 @@ def create_job(self):
116116 new_job = Job .create (new_job_id )
117117 new_job .set_experiment (self .id )
118118
119- # Update jobs index now that a new job exists
120- self .rebuild_jobs_index ()
121-
122119 return new_job
123120
124121 def get_jobs (self , type : str = "" , status : str = "" ):
@@ -127,6 +124,11 @@ def get_jobs(self, type: str = "", status: str = ""):
127124 type: If not blank, filter by jobs with this type.
128125 status: If not blank, filter by jobs with this status.
129126 """
127+
128+ # Rebuild the index
129+ # TODO: The point of the index is to not do this every time
130+ self .rebuild_jobs_index ()
131+
130132 # First get jobs of the passed type
131133 job_list = []
132134 if type :
@@ -143,6 +145,7 @@ def get_jobs(self, type: str = "", status: str = ""):
143145 job_json = job .get_json_data ()
144146 except Exception :
145147 continue
148+
146149 # Filter for status
147150 if status and (job_json .get ("status" , "" ) != status ):
148151 continue
@@ -154,7 +157,7 @@ def get_jobs(self, type: str = "", status: str = ""):
154157 # If it passed filters then add as long as it has job_data
155158 if "job_data" in job_json :
156159 results .append (job_json )
157-
160+
158161 return results
159162
160163 ###############################
0 commit comments