From f615ec89a339a7ff052df86f4031e9c48ac85f20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dandelion=20Man=C3=A9?= Date: Mon, 1 Jun 2020 18:04:47 -0700 Subject: [PATCH] cli2 writes CredResult as cred.json (#1833) This commit modifies the cli2 score command so that instead of writing the output format described in #1773, it instead writes the new CredResult format added in #1830. This is a much better engineered format, and will be useful for building a new frontend as well as for analysis by third parties (although we will need to provide client code for parsing it). Test plan: On a cli2 instance, run `sc2 score` and inspect the resulting cred.json file. --- src/cli2/score.js | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/cli2/score.js b/src/cli2/score.js index 7eb485b..5a1ab98 100644 --- a/src/cli2/score.js +++ b/src/cli2/score.js @@ -8,13 +8,8 @@ import type {Command} from "./command"; import {loadInstanceConfig} from "./common"; import {fromJSON as weightedGraphFromJSON} from "../core/weightedGraph"; import {defaultParams} from "../analysis/timeline/params"; -import {TimelineCred} from "../analysis/timeline/timelineCred"; import {LoggingTaskReporter} from "../util/taskReporter"; -import { - fromTimelineCredAndPlugins, - COMPAT_INFO as OUTPUT_COMPAT_INFO, -} from "../analysis/output"; -import {toCompat} from "../util/compat"; +import {compute, toJSON as credResultToJSON} from "../analysis/credResult"; function die(std, message) { std.err("fatal: " + message); @@ -40,15 +35,10 @@ const scoreCommand: Command = async (args, std) => { // TODO: Support loading params from config. const params = defaultParams(); - const tc = await TimelineCred.compute({ - weightedGraph: graph, - params, - plugins: declarations, - }); - const output = fromTimelineCredAndPlugins(tc, declarations); - const outputJSON = stringify(toCompat(OUTPUT_COMPAT_INFO, output)); - const outputPath = pathJoin(baseDir, "output", "cred.json"); - await fs.writeFile(outputPath, outputJSON); + const credResult = await compute(graph, params, declarations); + const credJSON = stringify(credResultToJSON(credResult)); + const outputPath = pathJoin(baseDir, "output", "credResult.json"); + await fs.writeFile(outputPath, credJSON); taskReporter.finish("score"); return 0; };