[Python] Add firehose Basics scenario + Hello - #8009
Conversation
7263cf3 to
6b36e88
Compare
There was a problem hiding this comment.
🤖 AI Code Example Review
This PR has addressed most of the blocking issues from the previous review (import error fixed, conftest.py added, unused imports removed, batch chunking implemented, static bucket name replaced with dynamic CFN bucket, cleanup now empties bucket before stack deletion). A few minor issues remain, but nothing blocking. The code is well-structured, tested, and largely follows AWS SDK example best practices.
Detailed Review
-
[ADDRESSED] Import error in test files: The previous blocking
from scenario_firehose_basics import FirehoseScenarioimport error has been fixed — the test file now imports fromfirehose_wrappercorrectly and theconftest.pyadds the parent directory tosys.path. This was the most critical blocker and is resolved. -
[ADDRESSED] conftest.py added:
python/example_code/firehose/test/conftest.pynow exists and properly patchessys.path, resolving the import resolution issue for bothfirehose_wrapperandfirehose_hello. -
[ADDRESSED] Unused imports removed:
firehose_wrapper.pyno longer importsjson,Optional,datetime, ortimezone. Onlylogging,time,typing,boto3, andbotocoreare imported — all are used. -
[ADDRESSED] Batch chunking in put_record_batch: The
put_record_batchmethod now properly chunks records into batches of up to 500 (configurable), aggregatesFailedPutCountandRequestResponsesacross all chunks, and returns a unified response. This resolves the previous spec-compliance concern. -
[ADDRESSED] Static S3 bucket name replaced: The CFN template now uses
Type: AWS::S3::Bucketwithout a fixedBucketName, letting CloudFormation generate a unique name. This resolves the re-run collision issue. -
[ADDRESSED] Cleanup ordering and bucket emptying: The
_cleanupmethod now waits for stream deletion before emptying the S3 bucket, and_empty_bucketusesbucket.object_versions.all().delete(). This resolves the previous CFN stack deletion failure risk. -
[REMAINING MINOR] test_firehose_scenario.py is truncated in the diff: The diff shows the file ends mid-line (
stubb) at the end ofTestFirehoseHello.test_hello_firehose. The full file content showsstubber.deactivate()is called, but the truncated diff makes it hard to verify the file is complete. This appears to be a diff artifact — the full file content looks complete. Not blocking. -
[REMAINING MINOR] No retry/backoff in put_record/put_record_batch: The spec explicitly requires 'retries with exponential back-off and jitter' for
ServiceUnavailableException. The code logs a message suggesting retries but does not implement them. The existingscenarios/firehose-put-actions/firehose.py(which this PR also modifies) usesbackoff.on_exceptionas a good pattern. Consider addingtenacityor documenting this limitation more explicitly. Low severity for an educational example, but the spec calls for it. -
[MINOR] README.md entry for scenario points to wrong file: The README says
python firehose_wrapper.pyto run the scenario, but the scenario entry point ispython scenarios/firehose_basics_scenario.py. The wrapper file does not have a runnable__main__block that exercises the full scenario. Users following the README will run the wrong file. -
[MINOR]
test_firehose_integ.pynot visible in the diff: The previous review flagged blocking issues withtest_firehose_integ.py(wrong import namescenario_firehose_basics). This file is referenced in the previous review but does not appear in the current diff — it's unclear if it was removed or simply not shown. If it still exists with the wrong import, it remains a blocker. The test file shown in this PR (test_firehose_scenario.py) is correct, but the integ test file status is unknown.
This review was generated automatically using Amazon Bedrock. It compares your changes against existing examples and coding guidelines. Please use your judgment — this is advisory, not authoritative.
…duplicate firehose-put-actions, fix README run command, add stream deletion wait
7afdd1b to
a309596
Compare
Summary
This PR adds Python code examples for firehose generated by the CodeLoom
automated pipeline.
Files Added
python/example_code/firehose/hello/hello_firehose.py— Hello World examplepython/example_code/firehose/scenarios/firehose_basics_scenario.py— Scenariopython/example_code/firehose/firehose_wrapper.py— Service wrapper classpython/example_code/firehose/test/test_firehose_integ.py— Integration testspython/example_code/firehose/requirements.txt— Dependencies.doc_gen/metadata/firehose_metadata.yaml— Metadata for doc generationOperations Covered
(See specification for full list)
Generation Details
amazon-firehose-spec-20260723-145332amazon-firehose-codegen-20260723-150835Review Checklist