def read_timings(self): """ The timing data for each atom should be stored in the atom directory. Parse them, associate them with their atoms, and return them. :rtype: dict [str, float] """ timings = {} for atom_id, atom in enumerate(self._atoms): artifact_dir = BuildArtifact.atom_artifact_directory( self.build_id(), self.subjob_id(), atom_id, result_root=Configuration['results_directory'] ) timings_file_path = os.path.join(artifact_dir, BuildArtifact.TIMING_FILE) if os.path.exists(timings_file_path): with open(timings_file_path, 'r') as f: atom.actual_time = float(f.readline()) timings[atom.command_string] = atom.actual_time else: self._logger.warning('No timing data for subjob {} atom {}.', self._subjob_id, atom_id) if len(timings) == 0: self._logger.warning('No timing data for subjob {}.', self._subjob_id) return timings
def test_atom_artifact_directory_returns_proper_artifact_path(self, expected_path, build_id, subjob_id=None, atom_id=None, result_root=None): self.assertEquals( expected_path, BuildArtifact.atom_artifact_directory(build_id, subjob_id, atom_id, result_root=result_root), 'The generated atom artifact directory is incorrect.' )
def read_timings(self): """ The timing data for each atom should be stored in the atom directory. Parse them, associate them with their atoms, and return them. :rtype: dict [str, float] """ timings = {} for atom_id, atom in enumerate(self._atoms): artifact_dir = BuildArtifact.atom_artifact_directory( self.build_id(), self.subjob_id(), atom_id, result_root=Configuration['results_directory']) timings_file_path = os.path.join(artifact_dir, BuildArtifact.TIMING_FILE) if os.path.exists(timings_file_path): with open(timings_file_path, 'r') as f: atom.actual_time = float(f.readline()) timings[atom.command_string] = atom.actual_time else: self._logger.warning('No timing data for subjob {} atom {}.', self._subjob_id, atom_id) if len(timings) == 0: self._logger.warning('No timing data for subjob {}.', self._subjob_id) return timings
def _parse_payload_for_atom_exit_code(self, subjob_id): subjob = self.subjob(subjob_id) for atom_id in range(len(subjob.atoms)): artifact_dir = BuildArtifact.atom_artifact_directory( self.build_id(), subjob.subjob_id(), atom_id, result_root=Configuration['results_directory'] ) atom_exit_code_file_sys_path = os.path.join(artifact_dir, BuildArtifact.EXIT_CODE_FILE) with open(atom_exit_code_file_sys_path, 'r') as atom_exit_code_file: subjob.atoms[atom_id].exit_code = int(atom_exit_code_file.read())
def test_atom_artifact_directory_returns_proper_artifact_path( self, expected_path, build_id, subjob_id=None, atom_id=None, result_root=None): self.assertEquals( expected_path, BuildArtifact.atom_artifact_directory(build_id, subjob_id, atom_id, result_root=result_root), 'The generated atom artifact directory is incorrect.')