@@ -217,96 +217,82 @@ async def add_job(
217
217
"""
218
218
start_time = time .time ()
219
219
220
- if uids is not None :
221
- valid_uids = uids
222
- else :
223
- valid_uids = await self .get_valid_uids ()
224
-
225
220
job_event ["uid_search_time" ] = time .time () - start_time
226
- selected_hotkeys = [self .metagraph .hotkeys [uid ] for uid in valid_uids ]
227
221
228
- if len (valid_uids ) >= self .config .neuron .sample_size :
229
- # If the job is organic, we still need to run the setup simulation to create the files needed for the job.
230
- if job_event .get ("is_organic" ):
231
- self .config .protein .input_source = job_event ["source" ]
232
- protein = Protein (** job_event , config = self .config .protein )
222
+ # If the job is organic, we still need to run the setup simulation to create the files needed for the job.
223
+ if job_event .get ("is_organic" ):
224
+ self .config .protein .input_source = job_event ["source" ]
225
+ protein = Protein (** job_event , config = self .config .protein )
233
226
234
- try :
235
- job_event ["pdb_id" ] = job_event ["pdb_id" ]
236
- job_event ["job_type" ] = "OrganicMD"
237
- job_event ["pdb_complexity" ] = [dict (protein .pdb_complexity )]
238
- job_event ["init_energy" ] = protein .init_energy
239
- job_event ["epsilon" ] = protein .epsilon
240
- job_event ["s3_links" ] = {
241
- "testing" : "testing"
242
- } # overwritten below if s3 logging is on.
243
- async with timeout (300 ):
244
- logger .info (
245
- f"setup_simulation for organic query: { job_event ['pdb_id' ]} "
246
- )
247
- await protein .setup_simulation ()
248
- logger .success (
249
- f"✅✅ organic { job_event ['pdb_id' ]} simulation ran successfully! ✅✅"
250
- )
227
+ try :
228
+ job_event ["pdb_id" ] = job_event ["pdb_id" ]
229
+ job_event ["job_type" ] = "OrganicMD"
230
+ job_event ["pdb_complexity" ] = [dict (protein .pdb_complexity )]
231
+ job_event ["init_energy" ] = protein .init_energy
232
+ job_event ["epsilon" ] = protein .epsilon
233
+ job_event ["s3_links" ] = {
234
+ "testing" : "testing"
235
+ } # overwritten below if s3 logging is on.
236
+ async with timeout (300 ):
237
+ logger .info (
238
+ f"setup_simulation for organic query: { job_event ['pdb_id' ]} "
239
+ )
240
+ await protein .setup_simulation ()
241
+ logger .success (
242
+ f"✅✅ organic { job_event ['pdb_id' ]} simulation ran successfully! ✅✅"
243
+ )
244
+
245
+ if protein .init_energy > 0 :
246
+ logger .error (
247
+ f"Initial energy is positive: { protein .init_energy } . Simulation failed."
248
+ )
249
+ job_event ["active" ] = False
251
250
252
- if protein .init_energy > 0 :
253
- logger .error (
254
- f"Initial energy is positive: { protein .init_energy } . Simulation failed."
251
+ if not self .config .s3 .off :
252
+ try :
253
+ logger .info (f"Uploading to { self .handler .bucket_name } " )
254
+ s3_links = await upload_to_s3 (
255
+ handler = self .handler ,
256
+ pdb_location = protein .pdb_location ,
257
+ simulation_cpt = protein .simulation_cpt ,
258
+ validator_directory = protein .validator_directory ,
259
+ pdb_id = job_event ["pdb_id" ],
260
+ VALIDATOR_ID = self .validator_hotkey_reference ,
255
261
)
262
+ job_event ["s3_links" ] = s3_links
263
+ logger .success ("✅✅ Simulation ran successfully! ✅✅" )
264
+ except Exception as e :
265
+ logger .error (f"Error in uploading to S3: { e } " )
266
+ logger .error ("❌❌ Simulation failed! ❌❌" )
256
267
job_event ["active" ] = False
257
268
258
- if not self .config .s3 .off :
259
- try :
260
- logger .info (f"Uploading to { self .handler .bucket_name } " )
261
- s3_links = await upload_to_s3 (
262
- handler = self .handler ,
263
- pdb_location = protein .pdb_location ,
264
- simulation_cpt = protein .simulation_cpt ,
265
- validator_directory = protein .validator_directory ,
266
- pdb_id = job_event ["pdb_id" ],
267
- VALIDATOR_ID = self .validator_hotkey_reference ,
268
- )
269
- job_event ["s3_links" ] = s3_links
270
- logger .success ("✅✅ Simulation ran successfully! ✅✅" )
271
- except Exception as e :
272
- logger .error (f"Error in uploading to S3: { e } " )
273
- logger .error ("❌❌ Simulation failed! ❌❌" )
274
- job_event ["active" ] = False
275
-
276
- except Exception as e :
277
- job_event ["active" ] = False
278
- logger .error (f"Error in setting up organic query: { e } " )
279
-
280
- logger .info (f"Inserting job: { job_event ['pdb_id' ]} " )
281
- try :
282
- job = self .store .upload_job (
283
- event = job_event ,
284
- hotkeys = selected_hotkeys ,
285
- keypair = self .wallet .hotkey ,
286
- gjp_address = self .config .neuron .gjp_address ,
287
- )
269
+ except Exception as e :
270
+ job_event ["active" ] = False
271
+ logger .error (f"Error in setting up organic query: { e } " )
288
272
289
- job_event ["job_id" ] = await self .store .confirm_upload (job_id = job .job_id )
273
+ logger .info (f"Inserting job: { job_event ['pdb_id' ]} " )
274
+ try :
275
+ job = self .store .upload_job (
276
+ event = job_event ,
277
+ keypair = self .wallet .hotkey ,
278
+ gjp_address = self .config .neuron .gjp_address ,
279
+ )
290
280
291
- if hasattr (job_event , "job_id" ) and job_event ["job_id" ] is None :
292
- raise ValueError ("job_id is None" )
281
+ job_event ["job_id" ] = await self .store .confirm_upload (job_id = job .job_id )
293
282
294
- logger .success ("Job was uploaded successfully!" )
283
+ if hasattr (job_event , "job_id" ) and job_event ["job_id" ] is None :
284
+ raise ValueError ("job_id is None" )
295
285
296
- self . last_time_created_jobs = datetime . now ( )
286
+ logger . success ( "Job was uploaded successfully!" )
297
287
298
- # TODO: return job_id
299
- return True
300
- except Exception as e :
301
- logger .warning (f"Error uploading job: { traceback .format_exc ()} " )
302
- job_event ["job_id" ] = None
288
+ self .last_time_created_jobs = datetime .now ()
303
289
304
- return False
290
+ # TODO: return job_id
291
+ return True
292
+ except Exception as e :
293
+ logger .warning (f"Error uploading job: { traceback .format_exc ()} " )
294
+ job_event ["job_id" ] = None
305
295
306
- else :
307
- logger .warning (
308
- f"Not enough available uids to create a job. Requested { self .config .neuron .sample_size } , but number of valid uids is { len (valid_uids )} ... Skipping until available"
309
- )
310
296
return False
311
297
312
298
async def add_k_synthetic_jobs (self , k : int ):
@@ -549,6 +535,9 @@ async def update_jobs(self):
549
535
job .event = eval (job .event ) # if str, convert to dict.
550
536
551
537
job .event .update (job_event )
538
+ job .hotkeys = [
539
+ self .metagraph .hotkeys [uid ] for uid in job .event ["uids" ]
540
+ ]
552
541
# Determine the status of the job based on the current energy and the previous values (early stopping)
553
542
# Update the DB with the current status
554
543
await self .update_job (job = job )
@@ -718,6 +707,7 @@ async def __aexit__(self, exc_type, exc_value, traceback):
718
707
logger .debug ("Stopping validator in background thread." )
719
708
self .should_exit = True
720
709
self .is_running = False
710
+ os .system ("pkill rqlited" )
721
711
self .loop .stop ()
722
712
logger .debug ("Stopped" )
723
713
0 commit comments