-
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
fix: remove log & data separation from base_local_service #4563
fix: remove log & data separation from base_local_service #4563
Conversation
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.
Overall seems like a good change. Just a couple small comments I would like a response on before accepting.
@@ -81,7 +82,7 @@ def service_response(body, headers, status_code): | |||
|
|||
class LambdaOutputParser: | |||
@staticmethod | |||
def get_lambda_output(stdout_stream): | |||
def get_lambda_output(stdout_stream: io.BytesIO) -> Tuple[str, bool]: |
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 wonder if NamedTuple
or a Dataclass would provide better readability and typing. I would not block on this but just stood out to me with the update.
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 do agree it would be better, but I didn't want to introduce more changes to this PR, I've only added some typing into the functions that is been changed.
lambda_response = stdout_data[last_line_position:].strip() | ||
|
||
lambda_response = lambda_response.decode("utf-8") | ||
lambda_response = stdout_stream.getvalue().decode("utf-8") |
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.
Do we still need the rstrip(b"\n")
after the getvalue
? We had it there before but not sure if it is strictly required anymore.
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've confirmed this by running local integration tests (some of them confirms the output of the command). So I believe we don't need that particular line
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.
LGTM
Which issue(s) does this change fix?
#4296
#3770
Why is this change necessary?
Before switching to use AWS Lambda RIE,
sam local
commands was trying to parse the output in STDOUT and were trying to distinguish the log messages vs the response of the lambda function.With switching to AWS Lambda RIE, function response is now gathered through an API call and written to STDOUT here
and function logs are written to STDERR in this thread. With this change, only function response is written to STDOUT and only function logging is written to STDERR.
How does it address the issue?
By removing the special logic to parse STDOUT in order to distinguish the logs with actual function response.
What side effects does this change have?
N/A
Mandatory Checklist
PRs will only be reviewed after checklist is complete
make pr
passesmake update-reproducible-reqs
if dependencies were changedBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.