From b863f8eaf0b2e2627fa9c5d2a51004fd8133cc68 Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Tue, 31 Jan 2023 16:20:12 +0100 Subject: MLIA-594 Save target profile configuration Save the target profile file in the output directory. Change-Id: I886e52cb922c5425e749b154bd67a5d294ce0201 --- src/mlia/cli/main.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/mlia/cli/main.py') diff --git a/src/mlia/cli/main.py b/src/mlia/cli/main.py index 76f199e..793e155 100644 --- a/src/mlia/cli/main.py +++ b/src/mlia/cli/main.py @@ -34,6 +34,7 @@ from mlia.core.context import ExecutionContext from mlia.core.errors import ConfigurationError from mlia.core.errors import InternalError from mlia.core.logging import setup_logging +from mlia.target.config import copy_profile_file_to_output_dir from mlia.target.registry import table as target_table @@ -174,7 +175,6 @@ def setup_context( if param_name not in skipped_params and (param_name not in expected_params or param_name in func_params) } - return (ctx, func_args) @@ -191,6 +191,11 @@ def run_command(args: argparse.Namespace) -> int: logger.info( "\nThis execution of MLIA uses output directory: %s", ctx.output_dir ) + if copy_profile_file(ctx, func_args): + logger.info( + "Target profile information copied to %s/target_profile.toml", + ctx.output_dir, + ) args.func(**func_args) return 0 except KeyboardInterrupt: @@ -261,6 +266,16 @@ def init_and_run(commands: list[CommandInfo], argv: list[str] | None = None) -> return run_command(args) +def copy_profile_file(ctx: ExecutionContext, func_args: dict) -> bool: + """If present, copy the target profile file to the output directory.""" + if func_args.get("target_profile"): + return copy_profile_file_to_output_dir( + func_args["target_profile"], ctx.output_dir + ) + + return False + + def main(argv: list[str] | None = None) -> int: """Entry point of the main application.""" commands = get_commands() -- cgit v1.2.1