Skip to content

Commit f34b8e0

Browse files
authored
Merge pull request #393 from macrocosm-os/staging
Staging
2 parents 34d9560 + adf2161 commit f34b8e0

File tree

5 files changed

+90
-101
lines changed

5 files changed

+90
-101
lines changed

folding/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "2.3.0"
1+
__version__ = "2.3.1"
22
version_split = __version__.split(".")
33
__spec_version__ = (
44
(10000 * int(version_split[0]))

folding/store.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ def __repr__(self):
241241
def upload_job(
242242
self,
243243
event: dict,
244-
hotkeys: list,
245244
keypair,
246245
gjp_address: str,
247246
**kwargs,
@@ -269,7 +268,7 @@ def upload_job(
269268
water=event["water"],
270269
system_kwargs=SystemKwargs(**event["system_kwargs"]),
271270
),
272-
hotkeys=hotkeys,
271+
hotkeys=[""],
273272
job_type=event["job_type"],
274273
created_at=pd.Timestamp.now().floor("s"),
275274
updated_at=pd.Timestamp.now().floor("s"),

neurons/validator.py

+66-76
Original file line numberDiff line numberDiff line change
@@ -217,96 +217,82 @@ async def add_job(
217217
"""
218218
start_time = time.time()
219219

220-
if uids is not None:
221-
valid_uids = uids
222-
else:
223-
valid_uids = await self.get_valid_uids()
224-
225220
job_event["uid_search_time"] = time.time() - start_time
226-
selected_hotkeys = [self.metagraph.hotkeys[uid] for uid in valid_uids]
227221

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)
233226

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
251250

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,
255261
)
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! ❌❌")
256267
job_event["active"] = False
257268

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}")
288272

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+
)
290280

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)
293282

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")
295285

296-
self.last_time_created_jobs = datetime.now()
286+
logger.success("Job was uploaded successfully!")
297287

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()
303289

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
305295

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-
)
310296
return False
311297

312298
async def add_k_synthetic_jobs(self, k: int):
@@ -549,6 +535,9 @@ async def update_jobs(self):
549535
job.event = eval(job.event) # if str, convert to dict.
550536

551537
job.event.update(job_event)
538+
job.hotkeys = [
539+
self.metagraph.hotkeys[uid] for uid in job.event["uids"]
540+
]
552541
# Determine the status of the job based on the current energy and the previous values (early stopping)
553542
# Update the DB with the current status
554543
await self.update_job(job=job)
@@ -718,6 +707,7 @@ async def __aexit__(self, exc_type, exc_value, traceback):
718707
logger.debug("Stopping validator in background thread.")
719708
self.should_exit = True
720709
self.is_running = False
710+
os.system("pkill rqlited")
721711
self.loop.stop()
722712
logger.debug("Stopped")
723713

0 commit comments

Comments
 (0)