diff options
Diffstat (limited to 'src/mlia/target')
-rw-r--r-- | src/mlia/target/config.py | 14 |
1 files changed, 14 insertions, 0 deletions
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") |