rosetta icon indicating copy to clipboard operation
rosetta copied to clipboard

Infinite while loop in PyJobDistributor

Open kellmnop opened this issue 11 months ago • 0 comments

There is a bug in the PyRosetta PyJobDistributor method start_decoy:

    def start_decoy(self):
        while self.sequence:

            self.current_id = self.sequence[0]
            self.current_name = self.pdb_name + "_" + str(self.current_id) + (".pdb.gz" if self.compress else ".pdb")
            self.current_in_progress_name = self.current_name + ".in_progress"

            if (not os.path.isfile(self.current_name)) and (not os.path.isfile(self.current_in_progress_name)):
                with open(self.current_in_progress_name, "w") as f:
                    f.write("This decoy is in progress.")
                print("Working on decoy: {}".format(self.current_name))
                break

If the current file in sequence is complete or in progress, in the case of multiple processes working on the same job in parallel, the while loop stalls on this decoy. Adding something like this else block after will solve the issue.

    def start_decoy(self):
        while self.sequence:

            self.current_id = self.sequence[0]
            self.current_name = self.pdb_name + "_" + str(self.current_id) + (".pdb.gz" if self.compress else ".pdb")
            self.current_in_progress_name = self.current_name + ".in_progress"

            if (not os.path.isfile(self.current_name)) and (not os.path.isfile(self.current_in_progress_name)):
                with open(self.current_in_progress_name, "w") as f:
                    f.write("This decoy is in progress.")
                print("Working on decoy: {}".format(self.current_name))
                break
            else:
                self.sequence.remove(self.current_id)

kellmnop avatar Mar 05 '25 18:03 kellmnop