def test_process_raw_metrics_with_no_path(): app.mock_app() metrics = {"metric": "1"} mapping = [{"key": "metric"}] nose.assert_equal( met.process_raw_metrics(app.mock_app(), metrics, mapping), {"metric": 1})
def test_process_raw_metrics_with_only_path(): app.mock_app() metrics = {"old_name": 1} mapping = [{"key": "new_name", "path": "old_name"}] nose.assert_equal( met.process_raw_metrics(app.mock_app(), metrics, mapping), {"new_name": 1})
def test_process_raw_metrics_with_unmappable_value(): metrics = {"old_name": "unmappable_value"} mapping = [{ "key": "new_name", "path": "old_name", "lift": ["parse_quast_value"] }] parsed = met.process_raw_metrics(app.mock_app(), metrics, mapping) nose.assert_equal(parsed, {})
def collect_metrics(self, app): path = fs.get_task_path_file_without_name(app, 'outputs/assembly_metrics') with open(path, 'r') as f: raw_metrics = list(csv.reader(f, delimiter='\t')) mapping_file = os.path.join('mappings', self.metric_mapping_file(app) + '.yml') mapping = yaml.safe_load(util.get_asset_file_contents(mapping_file)) return met.process_raw_metrics(app, dict(raw_metrics), mapping)
def test_process_raw_metrics_with_lift(): metrics = {"old_name": "-"} mapping = [{ "key": "new_name", "path": "old_name", "lift": ["parse_quast_value"] }] parsed = met.process_raw_metrics(app.mock_app(), metrics, mapping) nose.assert_equal(parsed, {"new_name": 0.0}) nose.assert_is_instance(parsed["new_name"], float)
def collect_metrics(self, app): import json, gzip path = fs.get_task_file_path( app, "outputs/container_runtime_metrics/metrics.json.gz") if not os.path.isfile(path): return {} with gzip.open(path) as f: raw_metrics = json.loads(f.read()) mapping_file = os.path.join('mappings', self.metric_mapping_file(app) + '.yml') mapping = yaml.safe_load(util.get_asset_file_contents(mapping_file)) return met.process_raw_metrics(app, raw_metrics, mapping)
def test_process_raw_metrics_with_optional_missing_value(): metrics = {} mapping = [{"key": "new_name", "path": "old_name", "optional": True}] nose.assert_equal( met.process_raw_metrics(app.mock_app(), metrics, mapping), {"new_name": 0.0})