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/target/config.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/mlia/target') diff --git a/src/mlia/target/config.py b/src/mlia/target/config.py index ec3fb4c..bf603dd 100644 --- a/src/mlia/target/config.py +++ b/src/mlia/target/config.py @@ -7,6 +7,7 @@ from abc import ABC from abc import abstractmethod from dataclasses import dataclass from pathlib import Path +from shutil import copy from typing import Any from typing import cast from typing import TypeVar @@ -61,6 +62,19 @@ def get_target(target_profile: str | Path) -> str: return cast(str, profile["target"]) +def copy_profile_file_to_output_dir( + target_profile: str | Path, output_dir: str | Path +) -> bool: + """Copy the target profile file to output directory.""" + profile_file_path = get_profile_file(target_profile) + output_file_path = f"{output_dir}/{profile_file_path.stem}.toml" + try: + copy(profile_file_path, output_file_path) + return True + except OSError as err: + raise RuntimeError("Failed to copy profile file:", err.strerror) from err + + T = TypeVar("T", bound="TargetProfile") -- cgit v1.2.1