Skip to content

refactor(extended_gcsfs): replace BucketType with orthogonal BucketLayout and routing helpers - #1133

Merged
zhixiangli merged 1 commit into
fsspec:mainfrom
yuxin00j:refactor-rcu-bucket-layout
Nov 2, 2026
Merged

zhixiangli merged 1 commit into
fsspec:mainfrom
yuxin00j:refactor-rcu-bucket-layout

Conversation

@yuxin00j

@yuxin00j yuxin00j commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Replaces the monolithic BucketType enum in ExtendedGcsFileSystem with an orthogonal BucketLayout(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

  • Bucket layout model (gcsfs/extended_gcsfs.py):
    • Replace BucketType and gcs_file_types with StorageClass (RAPID, STANDARD, UNKNOWN), CachingTier (RAPID_CACHE, RAPID_CACHE_ULTRA, NONE), NamespaceLayout (HIERARCHICAL, NON_HIERARCHICAL, UNKNOWN), and the frozen BucketLayout dataclass with a BucketLayout.UNKNOWN preset and is_zonal, is_rcu, is_hierarchical and uses_grpc_data_path properties.
    • Rename _get_bucket_type, _lookup_bucket_type, and _sync_lookup_bucket_type to _get_bucket_layout, _lookup_bucket_layout, and _sync_lookup_bucket_layout, skipping cache insertion when storage_class == StorageClass.UNKNOWN.
    • Select ZonalFile vs. GCSFile in _open from bucket_layout.is_zonal.
  • Routing helpers (gcsfs/extended_gcsfs.py):
    • _is_zonal_bucket and _is_bucket_hns_enabled look up the bucket's BucketLayout and return its is_zonal / is_hierarchical property.
    • Add _is_rcu_bucket and _uses_grpc_data_path helpers (returning is_rcu / uses_grpc_data_path) for upcoming RCU read/write routing.
  • Tests and fixtures (gcsfs/tests/):
    • Update emulator patches, fixtures, and unit/integration tests from BucketType / _get_bucket_type / _lookup_bucket_type to BucketLayout / _get_bucket_layout / _lookup_bucket_layout.
    • Add gcsfs/tests/layouts.py with the layouts the tests use (zonal, standard and HNS, plus RCU and Rapid Cache variants) and an ALL_BUCKET_LAYOUTS tuple.
    • Add unit tests in gcsfs/tests/test_hns_unit.py covering layout detection from real StorageLayout responses, BucketLayout.UNKNOWN, _lookup_bucket_layout caching 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 _open tests run over ALL_BUCKET_LAYOUTS and check which file class _open returns.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread gcsfs/extended_gcsfs.py Resolved
Comment thread gcsfs/extended_gcsfs.py Resolved
Comment thread gcsfs/extended_gcsfs.py Resolved
Comment thread gcsfs/extended_gcsfs.py Resolved
Comment thread gcsfs/tests/test_hns_unit.py Resolved
@yuxin00j
yuxin00j force-pushed the refactor-rcu-bucket-layout branch from 775b71c to 621ead4 Compare October 30, 2026 03:17
@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.24%. Comparing base (b45114a) to head (8b853b0).
⚠️ Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zhixiangli zhixiangli left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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" or override in _get_bucket_layout
  • is_rcu returning caching_tier != CachingTier.NONE
  • _open routing on uses_grpc_data_path instead of is_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).

Comment thread gcsfs/tests/test_hns_unit.py Resolved
Comment thread gcsfs/tests/test_zonal_unit.py Resolved
Comment thread gcsfs/tests/test_hns_unit.py Resolved
Comment thread gcsfs/extended_gcsfs.py Resolved
Comment thread gcsfs/tests/conftest.py Resolved
Comment thread gcsfs/tests/derived/gcsfs_fixtures.py Resolved
@yuxin00j
yuxin00j force-pushed the refactor-rcu-bucket-layout branch from 9335beb to 8b853b0 Compare November 2, 2026 08:47
@zhixiangli
zhixiangli merged commit c783299 into fsspec:main Nov 2, 2026
11 checks passed
Mahalaxmibejugam added a commit to Mahalaxmibejugam/gcsfs that referenced this pull request Nov 3, 2026
Mock _lookup_bucket_layout with gcsfs.tests.layouts instead of the removed
BucketType/_lookup_bucket_type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants