Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore init behaviour #119

Merged
merged 1 commit into from
Jul 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading