-
Notifications
You must be signed in to change notification settings - Fork 162
Feat: Introduce ExtendedGcsFileSystem for Zonal Bucket gRPC Read Path #707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
ecbec0e
d506a60
9a70933
eb209f5
0b606b1
409c86e
8a4ca85
c5a9eae
e95495f
95440d5
dfcbb7f
f3d1031
20b36fc
c9f569a
e5fc935
50d30b3
cbf00b3
a202579
5064a97
ac276f6
dbecb12
37a495b
cba7d27
4ff9fe4
389a4b0
133b4fa
31b2a2f
e36b7ed
25cd0ef
8425464
75fecce
2b6af9c
b648df4
f71f4e8
1c99137
1099375
d834b07
bfd513f
efabe35
2ed3cc6
957d7b5
cd222cb
17618d5
064c286
8b2a8d9
b1f0117
b254a14
7983528
cdf574a
b411bef
c47b53f
e37d0fb
11af000
c4cf777
5714012
fccd43a
11dd722
a2b5077
0c3df8e
0e9c2ab
c3ad9b2
a8945c2
774b53d
90d0cf4
8672c28
5398cfe
1796455
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,27 @@ | ||
| import logging | ||
| import os | ||
|
|
||
| from ._version import get_versions | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
| __version__ = get_versions()["version"] | ||
| del get_versions | ||
| from .core import GCSFileSystem | ||
| from .mapping import GCSMap | ||
|
|
||
| if os.getenv("GCSFS_EXPERIMENTAL_ZB_HNS_SUPPORT", "false").lower() in ("true", "1"): | ||
| try: | ||
| from .extended_gcsfs import ExtendedGcsFileSystem as GCSFileSystem | ||
|
|
||
| logger.info( | ||
| "gcsfs experimental features enabled via GCSFS_EXPERIMENTAL_ZB_HNS_SUPPORT." | ||
| ) | ||
| except ImportError as e: | ||
| logger.warning( | ||
| f"GCSFS_EXPERIMENTAL_ZB_HNS_SUPPORT is set, but failed to import experimental features: {e}" | ||
| ) | ||
| # Fallback to core GCSFileSystem, do not register here | ||
|
|
||
| __all__ = ["GCSFileSystem", "GCSMap"] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may not be important, but GCSMap will still refer to the original GCSFileSystem regardless of the branch taken above.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently zonal feature is defaulted to false, so this shouldn't cause any issue. I've added a todo to handle this use case in future PRs once we have more clarity on this |
||
|
|
||
| from . import _version | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import os | ||
| import sys | ||
|
|
||
|
|
||
| class TestConditionalImport: | ||
| def setup_method(self, method): | ||
| """Setup for each test method.""" | ||
| self.original_env = os.environ.get("GCSFS_EXPERIMENTAL_ZB_HNS_SUPPORT") | ||
|
|
||
| # Snapshot original gcsfs modules | ||
| self.original_modules = { | ||
| name: mod for name, mod in sys.modules.items() if name.startswith("gcsfs") | ||
| } | ||
|
|
||
| # Unload gcsfs modules to force re-import during the test | ||
| modules_to_remove = list(self.original_modules.keys()) | ||
| for name in modules_to_remove: | ||
| if name in sys.modules: | ||
| del sys.modules[name] | ||
|
|
||
| def teardown_method(self, method): | ||
| """Teardown after each test method.""" | ||
| # Reset environment variable to its original state | ||
| if self.original_env is not None: | ||
| os.environ["GCSFS_EXPERIMENTAL_ZB_HNS_SUPPORT"] = self.original_env | ||
| elif "GCSFS_EXPERIMENTAL_ZB_HNS_SUPPORT" in os.environ: | ||
| del os.environ["GCSFS_EXPERIMENTAL_ZB_HNS_SUPPORT"] | ||
|
|
||
| # Clear any gcsfs modules loaded/modified during this test | ||
| modules_to_remove = [name for name in sys.modules if name.startswith("gcsfs")] | ||
| for name in modules_to_remove: | ||
| if name in sys.modules: | ||
| del sys.modules[name] | ||
|
|
||
| # Restore the original gcsfs modules from the snapshot to avoid side effect | ||
| # affecting other tests | ||
| sys.modules.update(self.original_modules) | ||
|
|
||
| def test_experimental_env_unset(self): | ||
| """ | ||
| Tests gcsfs.GCSFileSystem is core.GCSFileSystem when | ||
| GCSFS_EXPERIMENTAL_ZB_HNS_SUPPORT is NOT set. | ||
| """ | ||
| if "GCSFS_EXPERIMENTAL_ZB_HNS_SUPPORT" in os.environ: | ||
| del os.environ["GCSFS_EXPERIMENTAL_ZB_HNS_SUPPORT"] | ||
|
|
||
| import gcsfs | ||
|
|
||
| assert ( | ||
| gcsfs.GCSFileSystem is gcsfs.core.GCSFileSystem | ||
| ), "Should be core.GCSFileSystem" | ||
| assert not hasattr( | ||
| gcsfs, "ExtendedGcsFileSystem" | ||
| ), "ExtendedGcsFileSystem should not be imported directly on gcsfs" | ||
|
|
||
| def test_experimental_env_set(self): | ||
| """ | ||
| Tests gcsfs.GCSFileSystem is extended_gcsfs.ExtendedGcsFileSystem when | ||
| GCSFS_EXPERIMENTAL_ZB_HNS_SUPPORT IS set. | ||
| """ | ||
| os.environ["GCSFS_EXPERIMENTAL_ZB_HNS_SUPPORT"] = "true" | ||
|
|
||
| import gcsfs | ||
|
|
||
| assert ( | ||
| gcsfs.GCSFileSystem is gcsfs.extended_gcsfs.ExtendedGcsFileSystem | ||
| ), "Should be ExtendedGcsFileSystem" |
Uh oh!
There was an error while loading. Please reload this page.