From 201e0857506b639aed8fc9a34c8b4be97904a6b5 Mon Sep 17 00:00:00 2001 From: mccrindlebrian Date: Tue, 15 Apr 2025 14:43:07 -0500 Subject: [PATCH] fix bug where job creation fails making job_id None --- folding/registries/evaluation_registry.py | 14 +++++++------- folding/validators/reward.py | 6 ++---- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/folding/registries/evaluation_registry.py b/folding/registries/evaluation_registry.py index bf71f0d0..688d8cb9 100644 --- a/folding/registries/evaluation_registry.py +++ b/folding/registries/evaluation_registry.py @@ -38,6 +38,7 @@ def __init__( basepath: str, system_config: SimulationConfig, velm_array_pkl_path: str, + job_id: str = None, **kwargs, ): self.pdb_id = pdb_id @@ -64,6 +65,7 @@ def __init__( self.intermediate_checkpoint_files = {} self.miner_reported_energies = {} + self.job_id = job_id def process_md_output(self) -> bool: """Method to process molecular dynamics data from a miner and recreate the simulation. @@ -299,7 +301,7 @@ def select_stratified_checkpoints( ] return selected - async def is_run_valid(self, validator=None, job_id=None, axon=None): + async def is_run_valid(self, validator=None, axon=None): """ Checks if the run is valid by evaluating a set of logical conditions: @@ -310,7 +312,6 @@ async def is_run_valid(self, validator=None, job_id=None, axon=None): Args: validator: Optional validator instance to query for intermediate checkpoints - job_id: Optional job ID to pass to get_intermediate_checkpoints axon: Optional axon to query for intermediate checkpoints Returns: @@ -342,7 +343,7 @@ async def is_run_valid(self, validator=None, job_id=None, axon=None): return False, checked_energies_dict, miner_energies_dict, result # Check the intermediate checkpoints - if validator is not None and job_id is not None and axon is not None: + if validator is not None and self.job_id is not None and axon is not None: checkpoint_numbers = self.select_stratified_checkpoints( num_checkpoints=self.number_of_checkpoints, num_samples=c.MAX_CHECKPOINTS_TO_VALIDATE + 1, # +1 for Final @@ -351,7 +352,7 @@ async def is_run_valid(self, validator=None, job_id=None, axon=None): # Get intermediate checkpoints from the miner intermediate_checkpoints = await self.get_intermediate_checkpoints( validator=validator, - job_id=job_id, + job_id=self.job_id, axon=axon, checkpoint_numbers=checkpoint_numbers, ) @@ -442,13 +443,12 @@ def evaluate(self) -> bool: return True - async def validate(self, validator=None, job_id=None, axon=None): + async def validate(self, validator=None, axon=None): """ Validate the run by checking if it's valid and returning the appropriate metrics. Args: validator: Optional validator instance to query for intermediate checkpoints - job_id: Optional job ID to pass to get_intermediate_checkpoints axon: Optional axon to query for intermediate checkpoints Returns: @@ -459,7 +459,7 @@ async def validate(self, validator=None, job_id=None, axon=None): checked_energies_dict, miner_energies_dict, result, - ) = await self.is_run_valid(validator=validator, job_id=job_id, axon=axon) + ) = await self.is_run_valid(validator=validator, axon=axon) if not is_valid: # Return empty dictionaries to maintain consistency diff --git a/folding/validators/reward.py b/folding/validators/reward.py index 2a61e8d0..3933d5ee 100644 --- a/folding/validators/reward.py +++ b/folding/validators/reward.py @@ -45,6 +45,7 @@ def evaluate( basepath=protein.pdb_directory, system_config=protein.system_config, velm_array_pkl_path=protein.velm_array_pkl, + job_id=resp.job_id, ) can_process = evaluator.evaluate() @@ -183,9 +184,7 @@ async def get_energies( checked_energies, miner_energies, reason, - ) = await evaluator.validate( - validator=validator, job_id=job_id, axon=axon - ) + ) = await evaluator.validate(validator=validator, axon=axon) else: ( median_energy, @@ -198,7 +197,6 @@ async def get_energies( evaluator.final_miner_energies, "skip", ) - # Add intermediate checkpoint files to files dictionary for ( checkpoint_num,