def _parse_log(self, log_path):
     log_path = self.input().path
     lines = fu.tail(log_path, 3)
     lines = [' '.join(ll.split()[2:]) for ll in lines]
     # load
     if lines[0].startswith("saving results to"):
         path = lines[0].split()[-1]
         assert os.path.exists(path)
         return path
     else:
         raise RuntimeError("Could not parse log file.")
Esempio n. 2
0
    def test_tail(self):
        from cluster_tools.utils.function_utils import tail
        l1 = 'abcd'
        l2 = '1234'
        l3 = '5678'
        l4 = 'wxyz'
        lines = (l1, l2, l3, l4)

        path = os.path.join(self.tmp_dir, 'out.txt')
        with open(path, 'w') as f:
            for l in lines:
                f.write(l + '\n')

        n_lines = 3
        out_lines = tail(path, n_lines)
        self.assertEqual(len(out_lines), n_lines)
        for li, lo in zip(lines[1:], out_lines):
            self.assertEqual(li, lo)