From 89a29b806b73f2a583bd97dc9cfea8bee830e5c7 Mon Sep 17 00:00:00 2001 From: Wing Fung Lau <4760060+hawflau@users.noreply.github.com> Date: Fri, 16 Aug 2024 19:07:44 -0700 Subject: [PATCH] chore: update log (#7371) * chore: update log * fix log * black reformat * update test --- samcli/lib/build/app_builder.py | 2 +- samcli/lib/build/build_graph.py | 6 +++++- samcli/lib/build/build_strategy.py | 3 +-- samcli/lib/providers/provider.py | 10 ++++++++++ tests/integration/buildcmd/build_integ_base.py | 6 +++--- 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/samcli/lib/build/app_builder.py b/samcli/lib/build/app_builder.py index 71124a6f30..8300a721f8 100644 --- a/samcli/lib/build/app_builder.py +++ b/samcli/lib/build/app_builder.py @@ -412,7 +412,7 @@ def _build_lambda_image(self, function_name: str, metadata: Dict, architecture: docker_tag = "-".join([docker_tag, docker_build_args["SAM_BUILD_MODE"]]) if isinstance(docker_build_args, dict): - LOG.info("Setting DockerBuildArgs: %s for %s function", docker_build_args, function_name) + LOG.info("Setting DockerBuildArgs for %s function", function_name) build_args = { "path": str(docker_context_dir), diff --git a/samcli/lib/build/build_graph.py b/samcli/lib/build/build_graph.py index 78085ad4d3..5a3ecf8e1d 100644 --- a/samcli/lib/build/build_graph.py +++ b/samcli/lib/build/build_graph.py @@ -648,10 +648,14 @@ def _validate_functions(self) -> None: raise InvalidBuildGraphException("Build definition doesn't have any function definition to build") def __str__(self) -> str: + metadata = self.metadata.copy() + if "DockerBuildArgs" in metadata: + del metadata["DockerBuildArgs"] + return ( "BuildDefinition(" f"{self.runtime}, {self.codeuri}, {self.packagetype}, {self.source_hash}, " - f"{self.uuid}, {self.metadata}, {self.env_vars}, {self.architecture}, " + f"{self.uuid}, {metadata}, {self.env_vars}, {self.architecture}, " f"{[f.functionname for f in self.functions]})" ) diff --git a/samcli/lib/build/build_strategy.py b/samcli/lib/build/build_strategy.py index dbbf03a64b..87b412b41c 100644 --- a/samcli/lib/build/build_strategy.py +++ b/samcli/lib/build/build_strategy.py @@ -146,10 +146,9 @@ def build_single_function_definition(self, build_definition: FunctionBuildDefini """ function_build_results = {} LOG.info( - "Building codeuri: %s runtime: %s metadata: %s architecture: %s functions: %s", + "Building codeuri: %s runtime: %s architecture: %s functions: %s", build_definition.codeuri, build_definition.runtime, - build_definition.metadata, build_definition.architecture, build_definition.get_resource_full_paths(), ) diff --git a/samcli/lib/providers/provider.py b/samcli/lib/providers/provider.py index 8fc32200b4..d9033785fb 100644 --- a/samcli/lib/providers/provider.py +++ b/samcli/lib/providers/provider.py @@ -168,6 +168,16 @@ def architecture(self) -> str: ) return str(arch_list[0]) + def __str__(self) -> str: + metadata = None if not self.metadata else self.metadata.copy() + if metadata and "DockerBuildArgs" in metadata: + del metadata["DockerBuildArgs"] + + copy = self._asdict() + if metadata: + copy["metadata"] = metadata + return f"Function({copy})" + class ResourcesToBuildCollector: def __init__(self) -> None: diff --git a/tests/integration/buildcmd/build_integ_base.py b/tests/integration/buildcmd/build_integ_base.py index 859c325bb1..5613ecc527 100644 --- a/tests/integration/buildcmd/build_integ_base.py +++ b/tests/integration/buildcmd/build_integ_base.py @@ -921,7 +921,7 @@ def _verify_process_code_and_output(self, command_result): # check HelloWorld and HelloMars functions are built in the same build self.assertRegex( command_result.stderr.decode("utf-8"), - "Building codeuri: .* runtime: .* metadata: .* functions: " "HelloWorldFunction, HelloMarsFunction", + "Building codeuri: .* runtime: .* functions: " "HelloWorldFunction, HelloMarsFunction", ) @@ -959,7 +959,7 @@ def _verify_process_code_and_output(self, command_result, function_full_paths): for function_full_path in function_full_paths: self.assertRegex( command_result.stderr.decode("utf-8"), - f"Building codeuri: .* runtime: .* metadata: .* functions: .*{function_full_path}.*", + f"Building codeuri: .* runtime: .* functions: .*{function_full_path}.*", ) def _verify_invoke_built_functions(self, template_path, overrides, function_and_expected): @@ -1004,7 +1004,7 @@ def _verify_process_code_and_output(self, command_result, function_full_paths, l for function_full_path in function_full_paths: self.assertRegex( command_result.stderr.decode("utf-8"), - f"Building codeuri: .* runtime: .* metadata: .* functions:.*{function_full_path}.*", + f"Building codeuri: .* runtime: .* functions:.*{function_full_path}.*", ) self.assertIn( f"Building layer '{layer_full_path}'",