Repository navigation
refactor(extended_gcsfs): replace BucketType with orthogonal BucketLayout and routing helpers - #1133
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors bucket type detection in gcsfs by replacing the BucketType enum with a more detailed BucketLayout dataclass, which encapsulates StorageClass, CachingTier, and NamespaceLayout enums. This change supports advanced bucket configurations like Rapid Cache Ultra (RCU) and hierarchical namespaces, and updates all corresponding methods, tests, and mocks. The review feedback suggests declaring the preset layouts as ClassVar inside BucketLayout for better static analysis, optimizing _uses_grpc_data_path to prevent duplicate API calls for uncached buckets, and removing redundant type checks and legacy string types from the implementation and tests.
775b71c to
621ead4
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1133 +/- ##
==========================================
+ Coverage 92.17% 92.24% +0.06%
==========================================
Files 20 20
Lines 4011 4047 +36
==========================================
+ Hits 3697 3733 +36
Misses 314 314 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
cf44b7b to
c71a288
Compare
c71a288 to
b234795
Compare
3ac7da1 to
9335beb
Compare
zhixiangli
left a comment
There was a problem hiding this comment.
Thanks — the orthogonal BucketLayout model reads well. I checked the "no behavior change" claim against real buckets (zonal → ZonalFile / HNS, HNS → hierarchical, flat → non-hierarchical, missing bucket → UNKNOWN and not cached), and it holds.
My main concern is test coverage of the new routing. I ran a few code mutations against test_hns_unit.py + test_zonal_unit.py, and these pass the whole suite:
- dropping the
location_type == "zone" oroverride in_get_bucket_layout is_rcureturningcaching_tier != CachingTier.NONE_openrouting onuses_grpc_data_pathinstead ofis_zonal
Routing _open on is_hierarchical is only caught by tests hanging until a timeout. The inline suggestions below make each of these fail with a clear assertion (checked locally).
9335beb to
8b853b0
Compare
Mock _lookup_bucket_layout with gcsfs.tests.layouts instead of the removed BucketType/_lookup_bucket_type.
Summary
Replaces the monolithic
BucketTypeenum inExtendedGcsFileSystemwith an orthogonalBucketLayout(storage_class, caching_tier, namespace_layout)model and capability-based routing helpers (_is_zonal_bucket,_is_rcu_bucket,_uses_grpc_data_path,_is_bucket_hns_enabled). This is a pure refactoring with no runtime behavior changes, preparing the codebase for Rapid Cache Ultra (RCU) support where storage class, caching tier, and namespace layout vary independently.Changes
gcsfs/extended_gcsfs.py):BucketTypeandgcs_file_typeswithStorageClass(RAPID,STANDARD,UNKNOWN),CachingTier(RAPID_CACHE,RAPID_CACHE_ULTRA,NONE),NamespaceLayout(HIERARCHICAL,NON_HIERARCHICAL,UNKNOWN), and the frozenBucketLayoutdataclass with aBucketLayout.UNKNOWNpreset andis_zonal,is_rcu,is_hierarchicalanduses_grpc_data_pathproperties._get_bucket_type,_lookup_bucket_type, and_sync_lookup_bucket_typeto_get_bucket_layout,_lookup_bucket_layout, and_sync_lookup_bucket_layout, skipping cache insertion whenstorage_class == StorageClass.UNKNOWN.ZonalFilevs.GCSFilein_openfrombucket_layout.is_zonal.gcsfs/extended_gcsfs.py):_is_zonal_bucketand_is_bucket_hns_enabledlook up the bucket'sBucketLayoutand return itsis_zonal/is_hierarchicalproperty._is_rcu_bucketand_uses_grpc_data_pathhelpers (returningis_rcu/uses_grpc_data_path) for upcoming RCU read/write routing.gcsfs/tests/):BucketType/_get_bucket_type/_lookup_bucket_typetoBucketLayout/_get_bucket_layout/_lookup_bucket_layout.gcsfs/tests/layouts.pywith the layouts the tests use (zonal, standard and HNS, plus RCU and Rapid Cache variants) and anALL_BUCKET_LAYOUTStuple.gcsfs/tests/test_hns_unit.pycovering layout detection from realStorageLayoutresponses,BucketLayout.UNKNOWN,_lookup_bucket_layoutcaching behavior, and the routing helpers (_is_zonal_bucket,_is_rcu_bucket,_uses_grpc_data_path,_is_bucket_hns_enabled) and properties for every layout.gcsfs/tests/test_zonal_unit.py: the_opentests run overALL_BUCKET_LAYOUTSand check which file class_openreturns.