-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat: SAM Init interactive flow redesign #3410
Conversation
fcee1b0
to
1113ae3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left small comments for now but I want to test this locally and give more detailed feedback later.
runtime = _get_runtime(runtime) | ||
dependency_manager = _get_dependency_manager(dependency_manager, runtime) | ||
templates = InitTemplates() | ||
filter_value = runtime if runtime else base_image |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 comments;
- Let's rename the
filter_value
to something more meaningful - What happens if
runtime
andbase_image
isNone
?
except KeyError as ex: | ||
raise InvalidInitOptionException(f"Lambda Runtime {runtime} is not supported for {use_case} examples.") from ex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't use exception driven development. This could easily change with another missing key on another dict. Please be explicit about which line can throw this.
|
||
try: | ||
dependency_manager_options = package_types_options[package_type] | ||
except KeyError as ex: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto. Please explicitly check the invalid case rather than raising an exception on KeyError
choice = click.prompt("Runtime", type=click.Choice(choices), show_choices=False) | ||
runtime = INIT_RUNTIMES[int(choice) - 1] # zero index | ||
return runtime | ||
def _generate_default_hello_world_application(use_case, package_type, runtime, dependency_manager, pt_explicit): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add documentation for these new methods?
1113ae3
to
4388d47
Compare
def get_template_value(value, template): | ||
if value not in template: | ||
raise InvalidInitTemplateError( | ||
f"Template is missing the value for {value} in manifest file. Please raise a a github issue." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Is it possible to include the url to raise an issue?
…ase prompt when --app-template is provided
12a77f1
to
c0927f7
Compare
return (runtime, package_type, dependency_manager, pt_explicit) | ||
|
||
|
||
def _get_app_template_properties(preprocessed_options, use_case, base_image, template_properties): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have some nice documentation for some of the methods, but some are missing. Can we add documentation for the ones that is not obvious what they are doing?
(app_template and app_template != template["appTemplate"]) | ||
or (package_type and package_type != template["packageType"]) | ||
or (dependency_manager and dependency_manager != template["dependencyManager"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(app_template and app_template != template["appTemplate"]) | |
or (package_type and package_type != template["packageType"]) | |
or (dependency_manager and dependency_manager != template["dependencyManager"]) | |
(app_template and app_template != template.get("appTemplate")) | |
or (package_type and package_type != template.get("packageType")) | |
or (dependency_manager and dependency_manager != template.get("dependencyManager")) |
* (fix) stop resolve relative paths for function imageUri * fix unit testing
* SAM INIT Update * resolved conflict * test added and updated * block default prompt when Image packageType is provide and skip use case prompt when --app-template is provided * update default hello world prompt * filtering updates * added typing * Fixing failed canaries (aws#3532) * (fix) stop resolving relative paths for Function image URI (aws#3531) * (fix) stop resolve relative paths for function imageUri * fix unit testing * update template_does_not_meet_filter_criteria use <dict>.get Co-authored-by: Mehmet Nuri Deveci <[email protected]> Co-authored-by: Qingchuan Ma <[email protected]> Co-authored-by: Mohamed Elasmar <[email protected]>
* SAM INIT Update * resolved conflict * test added and updated * block default prompt when Image packageType is provide and skip use case prompt when --app-template is provided * update default hello world prompt * filtering updates * added typing * Fixing failed canaries (aws#3532) * (fix) stop resolving relative paths for Function image URI (aws#3531) * (fix) stop resolve relative paths for function imageUri * fix unit testing * update template_does_not_meet_filter_criteria use <dict>.get Co-authored-by: Mehmet Nuri Deveci <[email protected]> Co-authored-by: Qingchuan Ma <[email protected]> Co-authored-by: Mohamed Elasmar <[email protected]>
Which issue(s) does this change fix?
Why is this change necessary?
Improve the user experience on the sam init interactive experience. Today we "hide" the types of app we support through a layer of questions (custom or pre made examples, Package type for lambda, what runtime, then show apps). While this works, we are moving to the idea of surfacing what examples we have first.
The new flow is something like:
custom or pre-made ---> here are the types of examples we have ----> from that list here are the package types ---> from that here are the runtimes.
How does it address the issue?
Improve the user experience on the sam init interactive experience
What side effects does this change have?
Changed the entire cli interactive flow
Checklist
make pr
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.