Add option to not show default keys when dumping
@@ -67,6 +67,7 @@ def _add_dump_checkpoint_parser(subparsers_dump):
)
parser_dump_checkpoint.add_argument(
"--keys",
+ "-k",
type=str,
nargs="*",
help="List of keys to include (separated by space)",
@@ -175,8 +176,12 @@ def _add_dump_trace_parser(subparsers_dump):
parser_dump_trace.add_argument(
argument, action="store_const", const=True, default=False,
)
+ parser_dump_trace.add_argument(
+ "--no-default-keys", "-K", action="store_const", const=True, default=False,
+ )
+
parser_dump_trace.add_argument("--keysfile", default=False)
- parser_dump_trace.add_argument("--keys", nargs="*", type=str)
+ parser_dump_trace.add_argument("--keys", "-k", nargs="*", type=str)
def _dump_trace(args):
@@ -258,10 +263,7 @@ def _dump_trace(args):
epoch_of_last=epoch,
)
if not entries and (args.search or not entry_type_specified):
- entries = Trace.grep_entries(
- tracefile=trace,
- conjunctions=[f"scope: train"],
- )
+ entries = Trace.grep_entries(tracefile=trace, conjunctions=[f"scope: train"],)
epoch = None
if entries:
args.search = True
@@ -275,6 +277,9 @@ def _dump_trace(args):
# dict[new_name] = (lookup_name, where)
# if where=="config"/"trace" it will be looked up automatically
# if where=="sep" it must be added in in the write loop separately
+ if args.no_default_keys:
+ default_attributes = OrderedDict()
+ else:
default_attributes = OrderedDict(
[
("job_id", ("job_id", "sep")),
@@ -292,6 +297,7 @@ def _dump_trace(args):
("metric", ("metric", "sep")),
]
)
+
if not args.no_header:
csv_writer.writerow(
list(default_attributes.keys()) + [key for key in keymap.keys()]
@@ -398,6 +404,9 @@ def _dump_trace(args):
actual_default["reciprocal"] = reciprocal
# lookup name is in config value is in trace
actual_default["metric"] = entry.get(config.get_default("valid.metric"))
+ for key in list(actual_default.keys()):
+ if key not in default_attributes:
+ del actual_default[key]
csv_writer.writerow(
[actual_default[new_key] for new_key in actual_default.keys()]
+ [new_attributes[new_key] for new_key in new_attributes.keys()]
