Skip to content

Commit

Permalink
Merge pull request #119 from E4S-Project/init-args-update
Browse files Browse the repository at this point in the history
Restore init behaviour
  • Loading branch information
spoutn1k authored Jul 17, 2023
2 parents cd959ec + 030dfe4 commit 59a1404
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions e4s_cl/cli/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down Expand Up @@ -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))

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 59a1404

Please sign in to comment.