def testRunDifferentMethod(self): self.config.target = DummyTask._DefaultName + ".runDataRef" task = TimingMetricTask(config=self.config) result = task.run(self.scienceTask.getFullMetadata()) lsst.pipe.base.testUtils.assertValidOutput(task, result) meas = result.measurement self.assertIsNone(meas)
def testBadlyTypedKeys(self): metadata = self.scienceTask.getFullMetadata() endKeys = [ key for key in metadata.paramNames(topLevelOnly=False) if "EndCpuTime" in key ] for key in endKeys: metadata.set(key, str(metadata.getAsDouble(key))) task = TimingMetricTask(config=self.config) with self.assertRaises(MetricComputationError): task.run(metadata)
def testNonsenseKeys(self): metadata = self.scienceTask.getFullMetadata() startKeys = [ key for key in metadata.paramNames(topLevelOnly=False) if "StartCpuTime" in key ] for key in startKeys: metadata.remove(key) task = TimingMetricTask(config=self.config) with self.assertRaises(MetricComputationError): task.run(metadata)
def _standardConfig(): config = TimingMetricTask.ConfigClass() config.connections.labelName = DummyTask._DefaultName config.target = DummyTask._DefaultName + ".run" config.connections.package = "verify" config.connections.metric = "DummyTime" return config
def testNoMetric(self): self.config.connections.package = "foo.bar" self.config.connections.metric = "FooBarTime" task = TimingMetricTask(config=self.config) with self.assertRaises(TypeError): task.run(self.scienceTask.getFullMetadata())
def makeTask(cls): return TimingMetricTask(config=cls._standardConfig())
def testRunDifferentMethod(self): self.config.target = DummyTask._DefaultName + ".runDataRef" task = TimingMetricTask(config=self.config) result = task.run([self.scienceTask.getFullMetadata()]) meas = result.measurement self.assertIsNone(meas)
def testNoMetric(self): self.config.metric = "foo.bar.FooBarTime" task = TimingMetricTask(config=self.config) with self.assertRaises(TypeError): task.run([self.scienceTask.getFullMetadata()])
def _standardConfig(): config = TimingMetricTask.ConfigClass() config.metadata.name = DummyTask._DefaultName + "_metadata" config.target = DummyTask._DefaultName + ".run" config.metric = "verify.DummyTime" return config
def testGetOutputMetricName(self): self.assertEqual(TimingMetricTask.getOutputMetricName(self.config), Name(self.config.metric))
def testGetInputDatasetTypes(self): types = TimingMetricTask.getInputDatasetTypes(self.config) self.assertSetEqual(set(types.keys()), {"metadata"}) expected = DummyTask._DefaultName + "_metadata" self.assertEqual(types["metadata"], expected)