def testFromPolicy(self): type = "CalExp" path = "goob/CalExp-v88-c12.fits" ccdid = 12 visitid = 88 p = Policy() p.set("type", type) # pdb.set_trace() ds = Dataset.fromPolicy(p) self.assertEquals(ds.type, type) self.assert_(ds.path is None) self.assert_(ds.ids is None) p.set("path", path) ds = Dataset.fromPolicy(p) self.assertEquals(ds.type, type) self.assertEquals(ds.path, path) self.assert_(ds.ids is None) p.set("ids.ccdid", ccdid) p.set("ids.visitid", visitid) ds = Dataset.fromPolicy(p) self.assertEquals(ds.type, type) self.assertEquals(ds.path, path) self.assert_(ds.ids is not None) self.assertEquals(ds.ids["ccdid"], ccdid) self.assertEquals(ds.ids["visitid"], visitid)
def testMakeJobCommandEvent(self): ds = self.testDatasetFromProperty() dss = [ds] for i in xrange(1, 5): ds = copy.deepcopy(ds) ds.ids["ampid"] += 1 dss.append(ds) ods = Dataset("PostISR-CCD", visit=ds.ids["visitid"], ccd=ds.ids["ccdid"]) job = JobItem.createItem(ods, "ccdassembly", dss, ods) jev = self.joboffice.makeJobCommandEvent(job, 9993252, "testing") self.assertEquals(jev.getStatus(), "job:assign") self.assertEquals(jev.getRunId(), "testing") self.assertEquals(jev.getDestinationId(), 9993252) self.assert_(jev.getPropertySet().exists("inputs")) self.assert_(jev.getPropertySet().exists("outputs")) dodss = jev.getPropertySet().getArrayString("inputs") self.assertEquals(len(dodss), 5) i = 5 for ds in dodss: ds = Dataset.fromPolicy(unserializePolicy(ds)) self.assertEquals(ds.type, "PostISR") self.assertEquals(ds.ids["ampid"], i) self.assertEquals(ds.ids["visitid"], 44291) self.assertEquals(ds.ids["ccdid"], 3) self.assertEquals(ds.ids["raftid"], 33) self.assertEquals(ds.ids["snapid"], 0) i += 1
def _getDatasets(self, key): dss = self.getProperty(key) out = [] if dss: if not isinstance(dss, list): dss = [dss] for ds in dss: out.append(Dataset.fromPolicy(ds)) return out
def getDataset(self): """ return a Dataset instance describing this product or None if a description is not available. """ ds = self.getProperty(self.DATASET) if ds: ds = Dataset.fromPolicy(ds) return ds
def datasetFromProperty(self, policystr): """ convert the given string-encoded policy data into a Dataset @param policystr the policy data written into a string in PAF format. """ try: pol = unserializePolicy(policystr) return Dataset.fromPolicy(pol) except lsst.pex.exceptions.LsstCppException, ex: raise RuntimeError("Dataset encoding error: " + policystr)
def testToPolicy(self): type = "CalExp" path = "goob/CalExp-v88-c12.fits" ccdid = 12 visitid = 88 orig = Dataset(type, path, ccdid=ccdid, visitid=visitid) pol = orig.toPolicy() ds = Dataset.fromPolicy(pol) self.assertEquals(ds.type, type) self.assertEquals(ds.path, path) self.assert_(ds.ids is not None) self.assertEquals(ds.ids["ccdid"], ccdid) self.assertEquals(ds.ids["visitid"], visitid)
def unserializeDataset(datasetstr): """ turn PAF-serialized string back into a Dataset. This is the opposite of serializeDataset(). """ return Dataset.fromPolicy(unserializePolicy(datasetstr))
def _makeDataset(self): return Dataset.fromPolicy(utils.unserializePolicy(postisrdata))
def getJobIdentity(self): """ return a Dataset instance representing the unique identity of the Job. """ return Dataset.fromPolicy(self.getProperty(self.JOBIDENTITY))