fix: resolve runtime/setup issues in six 01-features samples - #2000
Open
rhbelson wants to merge 1 commit into
Open
fix: resolve runtime/setup issues in six 01-features samples#2000rhbelson wants to merge 1 commit into
rhbelson wants to merge 1 commit into
Conversation
- 03-strands-openai/agent.py: read Azure OpenAI credentials from env (AZURE_API_KEY/AZURE_API_BASE/AZURE_API_VERSION) and fail fast with a clear message instead of hardcoding <YOUR_API_KEY> placeholders that silently error - memory/00-getting-started/04-quickstart-boto3.py: append a timestamp suffix to the memory name so re-runs don't hit ValidationException on the unique-name rule - memory/00-getting-started/05-quickstart-agentcore-sdk.py: auto-create the execution role if MEMORY_EXECUTION_ROLE_ARN is unset (mirrors the boto3 quickstart) and give the memory a unique name per run - 01-observe/data_protection.py: correct the invalid managed data identifier PhoneNumber -> PhoneNumber-US in both the audit and de-identify policies - 04-outbound-auth-self-hosted/self_hosted_agent_oauth.py: auto-run create_cognito.sh (resolved relative to the script) and inject its exported values when the OAuth env vars are unset, so the sample runs end-to-end without manual copy-paste - waf/deploy.py: retry associate_web_acl on WAFUnavailableEntityException (gateway eventual consistency) with backoff Also cleaned pre-existing whole-file ruff findings in the touched files (import sort, explicit subprocess check=False, noqa on intentional demo broad-except) so the python-lint gate passes; no behavior change from the lint cleanup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Six
01-features/samples had code-level issues that prevented them from running cleanly. Each fix is applied and the touched file is gate-clean (ruff check+ruff format --checkunder the repo-root config,py_compileclean). Complements #1998 (CI-clean doc/CLI fixes) and #1999 (docstring + arity fixes) — no file overlap.Fixes
02-host/.../03-strands-openai/agent.py<YOUR_API_KEY>/<YOUR_API_BASE>/<YOUR_API_VERSION>→ opaque Azure auth failureAZURE_API_KEY/AZURE_API_BASE/AZURE_API_VERSION); fail fast with a clear message if unset04-manage-context/memory/00-getting-started/04-quickstart-boto3.pyQuickstartMemory→ValidationExceptionon re-runQuickstartMemory_{int(time.time()) % 100000}(underscore per the[a-zA-Z][a-zA-Z0-9_]{0,47}regex)06-observe/.../01-observe/data_protection.pydata-identifier/PhoneNumberis not a valid managed identifier → policy failsPhoneNumber-USin both the audit and de-identify statements05-auth/.../04-outbound-auth-self-hosted/self_hosted_agent_oauth.pycreate_cognito.shrun + copy 6 env vars; script path not resolved relative to itselfcreate_cognito.sh(resolved relative to__file__), parse its exported values, inject into the environment when the OAuth vars are unset;--create-cognitostill works07-centralize/.../gatewaylabproject/scripts/waf/deploy.pyassociate_web_aclfails withWAFUnavailableEntityException(gateway eventual consistency)04-manage-context/memory/00-getting-started/05-quickstart-agentcore-sdk.pyMEMORY_EXECUTION_ROLE_ARNset manually; hardcoded name fails on re-runLint cleanup (no behavior change)
Each touched file also carried pre-existing whole-file ruff debt that the
python-lintgate lints on any change. Cleaned it: import sort (I001), explicitcheck=Falseon a pre-existingsubprocess.runthat already handlesreturncode(PLW1510), and# noqaon intentional demo-style broad-excepthandlers (BLE001/S110) — consistent with the repo's tutorial-code philosophy (root config already relaxes E722).Testing
python3 -m py_compileclean on all six files.uvx ruff@0.16.4 check --config pyproject.toml→ All checks passed;ruff@0.16.4 format --check→ 6 files already formatted (repo-root config, as CI uses).