diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 796629f8faf..a42646b84e8 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -1,3 +1,5 @@ # .git-blame-ignore-revs # Normalize SPDX Copyright header de7b1ee3fae2e3cd7d81a24c17345040f76b1d75 +# Full linting pass for PHP +a89ae9751bb71d5fbd4c998adcd34c911c088a1c diff --git a/.github/workflows/docker-push.yml b/.github/workflows/docker-push.yml index b119ae1185f..9ba75dcba3a 100644 --- a/.github/workflows/docker-push.yml +++ b/.github/workflows/docker-push.yml @@ -38,7 +38,7 @@ jobs: - name: Login to Amazon ECR Public id: login-ecr-public - uses: aws-actions/amazon-ecr-login@v1 + uses: aws-actions/amazon-ecr-login@v2 with: registry-type: public diff --git a/cpp/example_code/mediaconvert/tests/MediaConvert_gtests.cpp b/cpp/example_code/mediaconvert/tests/MediaConvert_gtests.cpp index 33014aef930..6724a72f522 100644 --- a/cpp/example_code/mediaconvert/tests/MediaConvert_gtests.cpp +++ b/cpp/example_code/mediaconvert/tests/MediaConvert_gtests.cpp @@ -9,12 +9,42 @@ #include #include "mediaconvert_samples.h" +// Debug testing framework start. +#include + +class DebugMockHTTPClient : public MockHttpClient { +public: + DebugMockHTTPClient() {} + + std::shared_ptr + MakeRequest(const std::shared_ptr &request, + Aws::Utils::RateLimits::RateLimiterInterface *readLimiter, + Aws::Utils::RateLimits::RateLimiterInterface *writeLimiter) const override { + + auto result = MockHttpClient::MakeRequest(request, readLimiter, writeLimiter); + + std::cout << "DebugMockHTTPClient::MakeRequest URI " << request->GetURIString() + << ", query " << request->GetQueryString() + << ", result " << result.get() << "." << std::endl; + + return result; + } +}; +// Debug testing framework end. Aws::SDKOptions AwsDocTest::MediaConvert_GTests::s_options; std::unique_ptr AwsDocTest::MediaConvert_GTests::s_clientConfig; static const char ALLOCATION_TAG[] = "RDS_GTEST"; void AwsDocTest::MediaConvert_GTests::SetUpTestSuite() { + // Debug testing framework start. + s_options.loggingOptions.logger_create_fn = []() { + std::cerr << "Log create function called. " << std::endl; + return Aws::MakeShared( + ALLOCATION_TAG, Aws::Utils::Logging::LogLevel::Debug); + }; + s_options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Debug; + // Debug testing framework end. InitAPI(s_options); // s_clientConfig must be a pointer because the client config must be initialized @@ -72,7 +102,8 @@ void AwsDocTest::MediaConvert_GTests::AddCommandLineResponses( bool AwsDocTest::MediaConvert_GTests::suppressStdOut() { - return std::getenv("EXAMPLE_TESTS_LOG_ON") == nullptr; + // return std::getenv("EXAMPLE_TESTS_LOG_ON") == nullptr; + return false; // Temporary override to debug testing framework. } void AwsDocTest::MediaConvert_GTests::createEndpointCache() { @@ -107,24 +138,33 @@ int AwsDocTest::MyStringBuffer::underflow() { } AwsDocTest::MockHTTP::MockHTTP() { - mockHttpClient = Aws::MakeShared(ALLOCATION_TAG); + mockHttpClient = Aws::MakeShared( + ALLOCATION_TAG); // Debug testing framework. mockHttpClientFactory = Aws::MakeShared(ALLOCATION_TAG); mockHttpClientFactory->SetClient(mockHttpClient); SetHttpClientFactory(mockHttpClientFactory); requestTmp = CreateHttpRequest(Aws::Http::URI("https://test.com/"), Aws::Http::HttpMethod::HTTP_GET, Aws::Utils::Stream::DefaultResponseStreamFactoryMethod); + + std::cout << "AwsDocTest::MockHTTP::MockHTTP called." + << std::endl; // Debug testing framework. } AwsDocTest::MockHTTP::~MockHTTP() { + std::cout << "AwsDocTest::MockHTTP::~MockHTTP called." + << std::endl; // Debug testing framework. Aws::Http::CleanupHttp(); Aws::Http::InitHttp(); } bool AwsDocTest::MockHTTP::addResponseWithBody(const std::string &fileName, Aws::Http::HttpResponseCode httpResponseCode) { - - std::ifstream inStream(std::string(SRC_DIR) + "/" + fileName); + std::string filePath = std::string(SRC_DIR) + "/" + fileName; + std::cout << "AwsDocTest::MockHTTP::addResponseWithBody called with file " + << filePath + << "." << std::endl; // Debug testing framework. + std::ifstream inStream(filePath); if (inStream) { std::shared_ptr goodResponse = Aws::MakeShared( ALLOCATION_TAG, requestTmp); @@ -132,10 +172,14 @@ bool AwsDocTest::MockHTTP::addResponseWithBody(const std::string &fileName, goodResponse->SetResponseCode(httpResponseCode); goodResponse->GetResponseBody() << inStream.rdbuf(); mockHttpClient->AddResponseToReturn(goodResponse); + + std::cout << "AwsDocTest::MockHTTP::addResponseWithBody response added " + << goodResponse.get() + << "." << std::endl; // Debug testing framework. return true; } - std::cerr << "MockHTTP::addResponseWithBody open file error '" << fileName << "'." + std::cerr << "MockHTTP::addResponseWithBody open file error '" << filePath << "'." << std::endl; return false; diff --git a/cpp/example_code/s3/tests/gtest_list_buckets_disabling_dns_cache.cpp b/cpp/example_code/s3/tests/gtest_list_buckets_disabling_dns_cache.cpp index 7cdad7b6cd2..0f7a77112d8 100644 --- a/cpp/example_code/s3/tests/gtest_list_buckets_disabling_dns_cache.cpp +++ b/cpp/example_code/s3/tests/gtest_list_buckets_disabling_dns_cache.cpp @@ -16,8 +16,9 @@ #include "S3_GTests.h" namespace AwsDocTest { + // This test is flaky. Add the D to disable it. // NOLINTNEXTLINE(readability-named-parameter) - TEST_F(S3_GTests, list_buckets_diabling_dns_cache_2_) { + TEST_F(S3_GTests, list_buckets_disabling_dns_cache_2D_) { bool result = AwsDoc::S3::ListBucketDisablingDnsCache(*s_clientConfig); EXPECT_TRUE(result); diff --git a/cpp/example_code/ses/tests/ses_gtests.cpp b/cpp/example_code/ses/tests/ses_gtests.cpp index 10bc078fe9b..f41ec10fe44 100644 --- a/cpp/example_code/ses/tests/ses_gtests.cpp +++ b/cpp/example_code/ses/tests/ses_gtests.cpp @@ -7,23 +7,6 @@ #include #include -// Debug testing framework. -class DebugMockHTTPClient : public MockHttpClient { -public: - DebugMockHTTPClient() {} - - std::shared_ptr - MakeRequest(const std::shared_ptr &request, - Aws::Utils::RateLimits::RateLimiterInterface *readLimiter, - Aws::Utils::RateLimits::RateLimiterInterface *writeLimiter) const override { - - auto result = MockHttpClient::MakeRequest(request, readLimiter, writeLimiter); - - std::cout << "DebugMockHTTPClient::MakeRequest result " << result.get() << "." << std::endl; - - return result; - } -}; Aws::SDKOptions AwsDocTest::SES_GTests::s_options; std::unique_ptr AwsDocTest::SES_GTests::s_clientConfig; @@ -84,8 +67,7 @@ void AwsDocTest::SES_GTests::AddCommandLineResponses( } bool AwsDocTest::SES_GTests::suppressStdOut() { - // return std::getenv("EXAMPLE_TESTS_LOG_ON") == nullptr; - return false; // Temporary override to debug testing framework. + return std::getenv("EXAMPLE_TESTS_LOG_ON") == nullptr; } int AwsDocTest::MyStringBuffer::underflow() { @@ -100,29 +82,24 @@ int AwsDocTest::MyStringBuffer::underflow() { AwsDocTest::MockHTTP::MockHTTP() { - mockHttpClient = Aws::MakeShared(ALLOCATION_TAG); // Debug testing framework. + mockHttpClient = Aws::MakeShared(ALLOCATION_TAG); mockHttpClientFactory = Aws::MakeShared(ALLOCATION_TAG); mockHttpClientFactory->SetClient(mockHttpClient); SetHttpClientFactory(mockHttpClientFactory); requestTmp = CreateHttpRequest(Aws::Http::URI("https://test.com/"), Aws::Http::HttpMethod::HTTP_GET, Aws::Utils::Stream::DefaultResponseStreamFactoryMethod); - - std::cout << "AwsDocTest::MockHTTP::MockHTTP called." << std::endl; // Debug testing framework. } AwsDocTest::MockHTTP::~MockHTTP() { - std::cout << "AwsDocTest::MockHTTP::~MockHTTP called." << std::endl; // Debug testing framework. Aws::Http::CleanupHttp(); Aws::Http::InitHttp(); } bool AwsDocTest::MockHTTP::addResponseWithBody(const std::string &fileName, Aws::Http::HttpResponseCode httpResponseCode) { - std::string filePath = std::string(SRC_DIR) + "/" + fileName; - std::cout << "AwsDocTest::MockHTTP::addResponseWithBody called with file " << filePath - << "." << std::endl; // Debug testing framework. - std::ifstream inStream(filePath); + + std::ifstream inStream(std::string(SRC_DIR) + "/" + fileName); if (inStream) { std::shared_ptr goodResponse = Aws::MakeShared( ALLOCATION_TAG, requestTmp); @@ -130,13 +107,10 @@ bool AwsDocTest::MockHTTP::addResponseWithBody(const std::string &fileName, goodResponse->SetResponseCode(httpResponseCode); goodResponse->GetResponseBody() << inStream.rdbuf(); mockHttpClient->AddResponseToReturn(goodResponse); - - std::cout << "AwsDocTest::MockHTTP::addResponseWithBody response added " << goodResponse.get() - << "." << std::endl; // Debug testing framework. return true; } - std::cerr << "MockHTTP::addResponseWithBody open file error '" << filePath << "'." + std::cerr << "MockHTTP::addResponseWithBody open file error '" << fileName << "'." << std::endl; return false; diff --git a/cpp/run_automated_tests.py b/cpp/run_automated_tests.py index f596f382c29..ad1d3ef510f 100644 --- a/cpp/run_automated_tests.py +++ b/cpp/run_automated_tests.py @@ -115,9 +115,8 @@ def run_tests(run_files=[], type1=False, type2=False, type3=False): if type3: filters.append("*_3_") - filter_arg = "" - if len(filters) > 0: - filter_arg = f"--gtest_filter={':'.join(filters)}" + if len(filters) == 0: + filters.append("") # Run once with no filter. passed_tests = 0 failed_tests = 0 @@ -126,27 +125,32 @@ def run_tests(run_files=[], type1=False, type2=False, type3=False): os.makedirs(name=run_dir, exist_ok=True) os.chdir(run_dir) for run_file in run_files: - print(f"Calling '{run_file} {filter_arg}'.") - proc = subprocess.Popen( - [run_file, filter_arg], stdout=subprocess.PIPE, stderr=subprocess.STDOUT - ) - for line in proc.stdout: - line = line.decode("utf-8") - sys.stdout.write(line) - - match = re.search("\[ PASSED \] (\d+) test", line) - if match is not None: - passed_tests = passed_tests + int(match.group(1)) - continue - match = re.search("\[ FAILED \] (\d+) test", line) - if match is not None: - failed_tests = failed_tests + int(match.group(1)) - continue - - proc.wait() - - if proc.returncode != 0: - has_error = True + # Run each filter separately or the no filter case. + for filter in filters: + filter_arg = "" + if len(filter) > 0: + filter_arg = f"--gtest_filter={filter}" + print(f"Calling '{run_file} {filter_arg}'.") + proc = subprocess.Popen( + [run_file, filter_arg], stdout=subprocess.PIPE, stderr=subprocess.STDOUT + ) + for line in proc.stdout: + line = line.decode("utf-8") + sys.stdout.write(line) + + match = re.search("\[ PASSED \] (\d+) test", line) + if match is not None: + passed_tests = passed_tests + int(match.group(1)) + continue + match = re.search("\[ FAILED \] (\d+) test", line) + if match is not None: + failed_tests = failed_tests + int(match.group(1)) + continue + + proc.wait() + + if proc.returncode != 0: + has_error = True print("-" * 88) print(f"{passed_tests} tests passed.") diff --git a/gov2/bedrock-runtime/actions/invoke_model.go b/gov2/bedrock-runtime/actions/invoke_model.go index 1726c8b20c7..4b267b34f81 100644 --- a/gov2/bedrock-runtime/actions/invoke_model.go +++ b/gov2/bedrock-runtime/actions/invoke_model.go @@ -28,7 +28,7 @@ type InvokeModelWrapper struct { // Each model provider has their own individual request and response formats. // For the format, ranges, and default values for Anthropic Claude, refer to: -// https://docs.anthropic.com/claude/reference/complete_post +// https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-claude.html type ClaudeRequest struct { Prompt string `json:"prompt"` @@ -79,7 +79,7 @@ func (wrapper InvokeModelWrapper) InvokeClaude(prompt string) (string, error) { // Each model provider has their own individual request and response formats. // For the format, ranges, and default values for AI21 Labs Jurassic-2, refer to: -// https://docs.ai21.com/reference/j2-complete-ref +// https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-jurassic2.html type Jurassic2Request struct { Prompt string `json:"prompt"` diff --git a/javascriptv3/example_code/bedrock-runtime/actions/invoke-claude.js b/javascriptv3/example_code/bedrock-runtime/actions/invoke-claude.js index 181ea726a7b..3403dc0f59c 100644 --- a/javascriptv3/example_code/bedrock-runtime/actions/invoke-claude.js +++ b/javascriptv3/example_code/bedrock-runtime/actions/invoke-claude.js @@ -27,7 +27,7 @@ export const invokeClaude = async (prompt) => { /* The different model providers have individual request and response formats. * For the format, ranges, and default values for Anthropic Claude, refer to: - * https://docs.anthropic.com/claude/reference/complete_post + * https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-claude.html */ const payload = { prompt: enclosedPrompt, diff --git a/javascriptv3/example_code/bedrock-runtime/actions/invoke-jurassic2.js b/javascriptv3/example_code/bedrock-runtime/actions/invoke-jurassic2.js index 9c1f59fe1d3..6e4f498c84d 100644 --- a/javascriptv3/example_code/bedrock-runtime/actions/invoke-jurassic2.js +++ b/javascriptv3/example_code/bedrock-runtime/actions/invoke-jurassic2.js @@ -30,7 +30,7 @@ export const invokeJurassic2 = async (prompt) => { /* The different model providers have individual request and response formats. * For the format, ranges, and default values for AI21 Labs Jurassic-2, refer to: - * https://docs.ai21.com/reference/j2-complete-ref + * https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-jurassic2.html */ const payload = { prompt, diff --git a/javav2/example_code/bedrock-runtime/src/main/java/com/example/bedrockruntime/InvokeModel.java b/javav2/example_code/bedrock-runtime/src/main/java/com/example/bedrockruntime/InvokeModel.java index 346b3e593c3..c65c1d85f81 100644 --- a/javav2/example_code/bedrock-runtime/src/main/java/com/example/bedrockruntime/InvokeModel.java +++ b/javav2/example_code/bedrock-runtime/src/main/java/com/example/bedrockruntime/InvokeModel.java @@ -39,7 +39,7 @@ public static String invokeClaude(String prompt) { /* * The different model providers have individual request and response formats. * For the format, ranges, and default values for Anthropic Claude, refer to: - * https://docs.anthropic.com/claude/reference/complete_post + * https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-claude.html */ String claudeModelId = "anthropic.claude-v2"; @@ -89,7 +89,7 @@ public static String invokeJurassic2(String prompt) { * The different model providers have individual request and response formats. * For the format, ranges, and default values for AI21 Labs Jurassic-2, refer * to: - * https://docs.ai21.com/reference/j2-complete-ref + * https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-jurassic2.html */ String jurassic2ModelId = "ai21.j2-mid-v1"; @@ -190,7 +190,7 @@ public static String invokeStableDiffusion(String prompt, long seed, String styl * The different model providers have individual request and response formats. * For the format, ranges, and available style_presets of Stable Diffusion * models refer to: - * https://platform.stability.ai/docs/api-reference#tag/v1generation + * https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-stability-diffusion.html */ String stableDiffusionModelId = "stability.stable-diffusion-xl"; diff --git a/javav2/example_code/bedrock-runtime/src/main/java/com/example/bedrockruntime/InvokeModelAsync.java b/javav2/example_code/bedrock-runtime/src/main/java/com/example/bedrockruntime/InvokeModelAsync.java index eabe1ebbe89..aff36b6e412 100644 --- a/javav2/example_code/bedrock-runtime/src/main/java/com/example/bedrockruntime/InvokeModelAsync.java +++ b/javav2/example_code/bedrock-runtime/src/main/java/com/example/bedrockruntime/InvokeModelAsync.java @@ -4,13 +4,13 @@ package com.example.bedrockruntime; // snippet-start:[bedrock-runtime.java2.invoke_model_async.import] + import org.json.JSONArray; import org.json.JSONObject; import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider; import software.amazon.awssdk.core.SdkBytes; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeAsyncClient; -import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient; import software.amazon.awssdk.services.bedrockruntime.model.InvokeModelRequest; import software.amazon.awssdk.services.bedrockruntime.model.InvokeModelResponse; @@ -41,7 +41,7 @@ public static String invokeClaude(String prompt) { /* * The different model providers have individual request and response formats. * For the format, ranges, and default values for Anthropic Claude, refer to: - * https://docs.anthropic.com/claude/reference/complete_post + * https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-claude.html */ String claudeModelId = "anthropic.claude-v2"; @@ -103,7 +103,7 @@ public static String invokeJurassic2(String prompt) { /* * The different model providers have individual request and response formats. * For the format, ranges, and default values for Anthropic Claude, refer to: - * https://docs.anthropic.com/claude/reference/complete_post + * https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-claude.html */ String jurassic2ModelId = "ai21.j2-mid-v1"; @@ -232,7 +232,7 @@ public static String invokeStableDiffusion(String prompt, long seed, String styl * The different model providers have individual request and response formats. * For the format, ranges, and available style_presets of Stable Diffusion * models refer to: - * https://platform.stability.ai/docs/api-reference#tag/v1generation + * https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-stability-diffusion.html */ String stableDiffusionModelId = "stability.stable-diffusion-xl"; diff --git a/php/example_code/bedrock-runtime/BedrockRuntimeService.php b/php/example_code/bedrock-runtime/BedrockRuntimeService.php index 9033d56c519..01182939f5b 100644 --- a/php/example_code/bedrock-runtime/BedrockRuntimeService.php +++ b/php/example_code/bedrock-runtime/BedrockRuntimeService.php @@ -35,7 +35,7 @@ public function invokeClaude($prompt) { # The different model providers have individual request and response formats. # For the format, ranges, and default values for Anthropic Claude, refer to: - # https://docs.anthropic.com/claude/reference/complete_post + # https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-claude.html $completion = ""; @@ -74,7 +74,7 @@ public function invokeJurassic2($prompt) { # The different model providers have individual request and response formats. # For the format, ranges, and default values for AI21 Labs Jurassic-2, refer to: - # https://docs.ai21.com/reference/j2-complete-ref + # https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-jurassic2.html $completion = ""; @@ -144,7 +144,7 @@ public function invokeStableDiffusion(string $prompt, int $seed, string $style_p { # The different model providers have individual request and response formats. # For the format, ranges, and available style_presets of Stable Diffusion models refer to: - # https://platform.stability.ai/docs/api-reference#tag/v1generation + # https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-stability-diffusion.html $base64_image_data = ""; diff --git a/python/example_code/bedrock-runtime/bedrock_runtime_wrapper.py b/python/example_code/bedrock-runtime/bedrock_runtime_wrapper.py index 501cb4afbd7..72a6cfa1297 100644 --- a/python/example_code/bedrock-runtime/bedrock_runtime_wrapper.py +++ b/python/example_code/bedrock-runtime/bedrock_runtime_wrapper.py @@ -49,7 +49,7 @@ def invoke_claude(self, prompt): try: # The different model providers have individual request and response formats. # For the format, ranges, and default values for Anthropic Claude, refer to: - # https://docs.anthropic.com/claude/reference/complete_post + # https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-claude.html # Claude requires you to enclose the prompt as follows: enclosed_prompt = "Human: " + prompt + "\n\nAssistant:" @@ -89,7 +89,7 @@ def invoke_jurassic2(self, prompt): try: # The different model providers have individual request and response formats. # For the format, ranges, and default values for AI21 Labs Jurassic-2, refer to: - # https://docs.ai21.com/reference/j2-complete-ref + # https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-jurassic2.html body = { "prompt": prompt, @@ -165,7 +165,7 @@ def invoke_stable_diffusion(self, prompt, seed, style_preset=None): try: # The different model providers have individual request and response formats. # For the format, ranges, and available style_presets of Stable Diffusion models refer to: - # https://platform.stability.ai/docs/api-reference#tag/v1generation + # https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-stability-diffusion.html body = { "text_prompts": [{"text": prompt}], @@ -249,7 +249,7 @@ async def invoke_model_with_response_stream(self, prompt): try: # The different model providers have individual request and response formats. # For the format, ranges, and default values for Anthropic Claude, refer to: - # https://docs.anthropic.com/claude/reference/complete_post + # https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-claude.html # Claude requires you to enclose the prompt as follows: enclosed_prompt = "Human: " + prompt + "\n\nAssistant:"