Example #1
0
    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 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)
Example #3
0
    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 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
Example #5
0
 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
Example #6
0
 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
Example #7
0
 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
Example #8
0
 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
Example #9
0
 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 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)
Example #12
0
    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)
Example #13
0
def unserializeDataset(datasetstr):
    """
    turn PAF-serialized string back into a Dataset.  This is the opposite
    of serializeDataset().
    """
    return Dataset.fromPolicy(unserializePolicy(datasetstr))
Example #14
0
 def _makeDataset(self):
     return Dataset.fromPolicy(utils.unserializePolicy(postisrdata))
Example #15
0
 def getJobIdentity(self):
     """
     return a Dataset instance representing the unique identity of the Job.
     """
     return Dataset.fromPolicy(self.getProperty(self.JOBIDENTITY))
 def _makeDataset(self):
     return Dataset.fromPolicy(utils.unserializePolicy(postisrdata))
Example #17
0
def unserializeDataset(datasetstr):
    """
    turn PAF-serialized string back into a Dataset.  This is the opposite
    of serializeDataset().
    """
    return Dataset.fromPolicy(unserializePolicy(datasetstr))
Example #18
0
 def getJobIdentity(self):
     """
     return a Dataset instance representing the unique identity of the Job.
     """
     return Dataset.fromPolicy(self.getProperty(self.JOBIDENTITY))