summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBirte Kristina Friesel <birte.friesel@uos.de>2024-01-11 13:50:53 +0100
committerBirte Kristina Friesel <birte.friesel@uos.de>2024-01-11 13:50:53 +0100
commit9826f7cbad31ef0e04bf14e8b1ed2e95a81b4054 (patch)
treecc9882a2164fe9a7442f8192acd58092808053b8
parentcb30dd6e7a5f278c5655093f0322ab517c898a28 (diff)
add --export-json option
-rwxr-xr-xbin/analyze-archive.py4
-rwxr-xr-xbin/analyze-kconfig.py4
-rwxr-xr-xbin/analyze-log.py4
-rw-r--r--doc/model-visual.md5
-rw-r--r--lib/cli.py6
5 files changed, 23 insertions, 0 deletions
diff --git a/bin/analyze-archive.py b/bin/analyze-archive.py
index 9e5d4be..25565a5 100755
--- a/bin/analyze-archive.py
+++ b/bin/analyze-archive.py
@@ -837,6 +837,10 @@ if __name__ == "__main__":
args.export_dref, dref, precision=args.dref_precision
)
+ if args.export_json:
+ with open(args.export_json, "w") as f:
+ json.dump(model.to_json(), f, sort_keys=True, cls=dfatool.utils.NpEncoder)
+
if args.export_webconf:
if not pta:
print(
diff --git a/bin/analyze-kconfig.py b/bin/analyze-kconfig.py
index 78435b7..b114999 100755
--- a/bin/analyze-kconfig.py
+++ b/bin/analyze-kconfig.py
@@ -618,6 +618,10 @@ def main():
args.export_dref, dref, precision=args.dref_precision
)
+ if args.export_json:
+ with open(args.export_json, "w") as f:
+ json.dump(model.to_json(), f, sort_keys=True, cls=dfatool.utils.NpEncoder)
+
if args.config:
kconf = kconfiglib.Kconfig(args.kconfig_path)
kconf.load_config(args.config)
diff --git a/bin/analyze-log.py b/bin/analyze-log.py
index 1d92bc7..c74e206 100755
--- a/bin/analyze-log.py
+++ b/bin/analyze-log.py
@@ -258,6 +258,10 @@ def main():
args.export_dref, dref, precision=args.dref_precision
)
+ if args.export_json:
+ with open(args.export_json, "w") as f:
+ json.dump(model.to_json(), f, sort_keys=True, cls=dfatool.utils.NpEncoder)
+
if args.plot_param:
for kv in args.plot_param.split(";"):
try:
diff --git a/doc/model-visual.md b/doc/model-visual.md
index 25607ff..55433b5 100644
--- a/doc/model-visual.md
+++ b/doc/model-visual.md
@@ -23,3 +23,8 @@ In case of regression forests (XGBoost), dfatool exports the individual trees to
see [[analysis-visual.md]]) and the corresponding performance model (as lines).
The plot is saved to (name)-(attribute)-(parameter).pdf and shown interactively
unless `--non-interactive` has been specified.
+
+## JSON Export
+
+Use `--export-json FILENAME` to export the performance model to FILENAME.
+The model for NAME ATTRIBUTE is located in .name.NAME.ATTRIBUTE.modelFunction.
diff --git a/lib/cli.py b/lib/cli.py
index ae3bb7b..3fa39b3 100644
--- a/lib/cli.py
+++ b/lib/cli.py
@@ -394,6 +394,12 @@ def add_standard_arguments(parser):
help="Export raw (parameter-independent) observations in JSON format to FILENAME",
)
parser.add_argument(
+ "--export-json",
+ metavar="FILENAME",
+ type=str,
+ help="Export model in JSON format to FILENAME",
+ )
+ parser.add_argument(
"--dref-precision",
metavar="NDIG",
type=int,