Repository navigation
Core: Extract REST SigV4 signing into a dedicated module - #4493
Anurag-S1ngh wants to merge 2 commits into
Conversation
Fokko
left a comment
There was a problem hiding this comment.
Thanks @Anurag-S1ngh for picking this up, this makes the REST catalog module a lot easier to navigate 👍 There is one thing that needs fixing before we can merge: the move removes SIGV4_REGION, SIGV4_SERVICE, SIGV4_MAX_RETRIES, SIGV4_MAX_RETRIES_DEFAULT and EMPTY_BODY_SHA256 from pyiceberg.catalog.rest, so from pyiceberg.catalog.rest import SIGV4_REGION now raises an ImportError. Sorry, that's partly on me: ruff splits X as X imports into one statement per name, so the re-exports in your first commit were fine, and my comment about grouping them was misleading. The rest are small suggestions. Once this is in, #4586 needs a small rebase to move its change into sigv4.py.
Move SigV4Adapter, its constants, and the initialization helper out of RestCatalog._init_sigv4. Re-export the existing public names from catalog.rest for compatibility. Part of apache#3410; signing and retry fixes remain separate.
SigV4Adapter and init_sigv4 were private before the move, so expose them as _SigV4Adapter and _init_sigv4. Keep SIGV4_REGION, SIGV4_SERVICE, SIGV4_MAX_RETRIES, SIGV4_MAX_RETRIES_DEFAULT and EMPTY_BODY_SHA256 importable from pyiceberg.catalog.rest, as they were before the extraction. Carry over the request-body content hash and the blank query parameter handling from main so the module keeps the behavior it had before the move.
0570ef3 to
c29ef34
Compare
|
Rebased on main and addressed all three. The constants are re-exported from |
Rationale for this change
RestCatalog._init_sigv4currently contains the SigV4 adapter, signing constants, and boto session setup inside an already large catalog module.This extracts that code into
catalog/rest/sigv4.pyand replaces the method with aninit_sigv4(session, uri, properties)helper. The SigV4 constants andSigV4Adapternow live incatalog/rest/sigv4.py. Signing and retry behavior are unchanged.The retry behavior in #3008 and signing fixes in #3120 remain separate.
Part of #3410.
Are these changes tested?
Yes. The existing REST SigV4 tests exercise the extracted adapter through
RestCatalog.pytest tests/catalog/test_rest.py -m unit: 204 passedruff checkandgit diff --checkpassty checkreports nothing for the new module; existing catalog diagnostics are unchangedAre there any user-facing changes?
No behavior change.