From 030dfe48c8398cef91fab9efd9e4493590080e07 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Skutnik Date: Mon, 3 Jul 2023 08:46:36 -0700 Subject: [PATCH] Restore init behaviour --- e4s_cl/cli/commands/init.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/e4s_cl/cli/commands/init.py b/e4s_cl/cli/commands/init.py index d599ad2f..5a4f5cf8 100644 --- a/e4s_cl/cli/commands/init.py +++ b/e4s_cl/cli/commands/init.py @@ -362,7 +362,25 @@ def _filter_libraries( return list(filtered) -def optimize_profile(args: argparse.Namespace, profile_eid: int) -> int: +def _set_defaults(args: argparse.Namespace, profile_eid: int): + """ + Update the profile with the backend, image and source arguments from the command line + """ + controller = Profile.controller() + changes = {} + + for label in ["backend", "image", "source", "wi4mpi"]: + if label in args: + changes.update({label: getattr(args, label, "")}) + + # Update the profile + controller.update( + changes, + profile_eid, + ) + + +def _optimize_profile(args: argparse.Namespace, profile_eid: int) -> int: """ After the analysis has succeeded, agglomerate bound files and rename profile """ @@ -412,6 +430,8 @@ def optimize_profile(args: argparse.Namespace, profile_eid: int) -> int: selected_profile.eid, ) + _set_defaults(args, selected_profile.eid) + requested_name = (getattr(args, 'profile_name', None) or profile_mpi_name(profile_mpi_libraries)) @@ -535,7 +555,7 @@ def main(self, argv: List[str]) -> int: controller.delete(profile_eid) return status - status = optimize_profile(args, profile_eid) + status = _optimize_profile(args, profile_eid) LOGGER.info("Created profile %s", controller.selected().get('name')) return status