def test_6_update(self): """test that when something is changed, the unique id stays the same. """ dataset = Dataset(dataset_name_fccsw, xsection=1, cache=True) self.assertEqual(dataset.uid(), self.dataset.uid()) self.assertEqual(dataset.xsection(), 1) dataset.write() dataset = Dataset(dataset_name_fccsw, cache=True) self.assertEqual(dataset.xsection(), 1)
def process_dataset(dsname, options): ds = Dataset(dsname, pattern=options.wildcard, extract_info=options.extract, xsection=options.xsection, cache=False) ds.write() if options.verbose: print ds else: print dsname
class TestHeppyDataset(unittest.TestCase): def setUp(self): self.dataset = Dataset(dataset_name_heppy, dataset_pattern_heppy, cache=False, extract_info=True, cfg=cfg_name, xsection=1.8e-9) self.dataset.write() self.nfiles = 1 self.ngoodfiles = 1 self.nevents = 100 def test_1_create(self): '''Test dataset creation''' self.assertEqual(len(self.dataset.all_files), self.nfiles) self.assertEqual(len(self.dataset.list_of_good_files()), self.ngoodfiles) self.assertEqual(self.dataset.nfiles(), self.nfiles) self.assertEqual(self.dataset.ngoodfiles(), self.ngoodfiles) def test_2_cache(self): '''Test dataset reading from cache''' dataset = Dataset(dataset_name_heppy, cache=True) self.assertEqual(len(dataset.all_files), self.nfiles) self.assertEqual(len(dataset.list_of_good_files()), self.ngoodfiles) self.assertEqual(dataset.uid(), self.dataset.uid()) #---------------------------------------------------------------------- def test_3_nevents(self): """Test that the number of events is correct""" dataset = Dataset(dataset_name_heppy, cache=True) self.assertEqual(dataset.nevents(), self.nevents) #---------------------------------------------------------------------- def test_4_yaml(self): """Test that the yaml file can be written and read.""" dataset = Dataset(dataset_name_heppy, dataset_pattern_heppy, cache=cache) data_written = dataset._write_yaml() data_read = dataset._read_yaml() self.assertDictEqual(data_written, data_read) #---------------------------------------------------------------------- def test_5_jobtype_heppy(self): """test that the jobtype can be determined for heppy""" dataset = Dataset(dataset_name_heppy, dataset_pattern_heppy, cache=False, extract_info=True) self.assertEqual(dataset.jobtype(), 'heppy')
class TestPythia8Dataset(unittest.TestCase): def setUp(self): self.dataset = Dataset(dataset_name_pythia8, dataset_pattern_pythia8, cache=False, extract_info=True, cfg=cfg_name, xsection=1.8e-9) self.dataset.write() self.nfiles = 5 self.ngoodfiles = 5 self.nevents = 50 def test_1_create(self): '''Test dataset creation''' self.assertEqual(len(self.dataset.all_files), self.nfiles) self.assertEqual(len(self.dataset.list_of_good_files()), self.ngoodfiles) self.assertEqual(self.dataset.nfiles(), self.nfiles) self.assertEqual(self.dataset.ngoodfiles(), self.ngoodfiles) self.assertEqual(self.dataset.nevents(), self.nevents) self.assertEqual(self.dataset.jobtype(), 'pythia8')
class TestFccswDataset(unittest.TestCase): def setUp(self): self.dataset = Dataset(dataset_name_fccsw, dataset_pattern_fccsw, extract_info=True, cache=False, xsection=1.8e-9) self.dataset.write() self.nfiles = 10 self.ngoodfiles = 10 self.nevents = 10 def test_1_create(self): '''Test dataset creation''' self.assertEqual(len(self.dataset.all_files), self.nfiles) self.assertEqual(len(self.dataset.list_of_good_files()), self.ngoodfiles) self.assertEqual(self.dataset.nfiles(), self.nfiles) self.assertEqual(self.dataset.ngoodfiles(), self.ngoodfiles) def test_2_cache(self): '''Test dataset reading from cache''' dataset = Dataset(dataset_name_fccsw, cache=True) self.assertEqual(len(dataset.all_files), self.nfiles) self.assertEqual(len(dataset.list_of_good_files()), self.ngoodfiles) self.assertEqual(dataset.uid(), self.dataset.uid()) #---------------------------------------------------------------------- def test_3_nevents(self): """Test that the number of events is correct""" dataset = Dataset(dataset_name_fccsw, cache=True) self.assertEqual(dataset.nevents(), 100) #---------------------------------------------------------------------- def test_4_yaml(self): """Test that the yaml file can be written and read.""" dataset = Dataset(dataset_name_fccsw, cache=True) data_written = dataset._write_yaml() data_read = dataset._read_yaml() self.assertDictEqual(data_written, data_read) #---------------------------------------------------------------------- def test_5_jobtype_fccsw(self): """test that the jobtype can be determined for fccsw""" dataset = Dataset(dataset_name_fccsw, cache=True) self.assertEqual(dataset.jobtype(), 'fccsw') #---------------------------------------------------------------------- def test_6_update(self): """test that when something is changed, the unique id stays the same. """ dataset = Dataset(dataset_name_fccsw, xsection=1, cache=True) self.assertEqual(dataset.uid(), self.dataset.uid()) self.assertEqual(dataset.xsection(), 1) dataset.write() dataset = Dataset(dataset_name_fccsw, cache=True) self.assertEqual(dataset.xsection(), 1) def test_empty(self): """Check that an exception is raised when trying to read a dataset with no root file""" with self.assertRaises(ValueError): dataset = Dataset('papas/empty_dataset', '*.root', extract_info=True) def test_no_good_root_file(self): with self.assertRaises(ValueError): dataset = Dataset('papas/nogood_dataset', '*.root', extract_info=True) def test_no_yaml(self): with self.assertRaises(IOError): dataset = Dataset('papas/empty_dataset', '*.root', extract_info=False)
outdir = '/'.join( (condor_pars["base_outputdir"], condor_pars["subdirectory"])) #create a touch file (will be removed at the end if everything works) filename = '/'.join((outdir, "finish.txt")) os.system("touch " + filename) curdir = os.getcwd() #move to the output directory os.chdir(condor_pars["base_outputdir"]) '''base directory where outputs are stored''' basedir.set_basename(condor_pars["base_outputdir"]) ds = Dataset(condor_pars["subdirectory"], pattern="*.root", xsection=None, extract_info=True, cache=False) ds.write() print "ls" os.system("ls -al " + outdir) #put a copy of inf.yaml in the work directory for easy reference os.system("cp " + condor_pars["subdirectory"] + "/info.yaml " + curdir) #remove the touch file os.system("rm " + filename) #move back to the original directory os.chdir(curdir) print "finished creation of info.yaml"