Skip to content

Commit 7da83e8

Browse files
author
崔佳磊
committed
chore: disable blob cache by default
1 parent 9a49d40 commit 7da83e8

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

client/starwhale/base/cloud_blob_cache.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ def __init__(self, ip: str) -> None:
1919

2020

2121
def init() -> None:
22+
enable_blob_cache = os.getenv("SW_ENABLE_BLOB_CACHE", "false").lower() == "true"
2223
global _servers
23-
if _servers is None:
24+
if not enable_blob_cache:
25+
_servers = []
26+
elif _servers is None:
2427
try:
2528
_servers = [
2629
_Server(ip) for ip in socket.gethostbyname_ex(_pseudo_host_name)[2]

client/tests/base/test_cloud_blob_cache.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
from unittest import TestCase
23
from unittest.mock import patch, MagicMock
34

@@ -13,6 +14,15 @@ def test_replace_url(self, gethostbyname_ex: MagicMock) -> None:
1314
)
1415

1516
gethostbyname_ex.return_value = ("localhost", [], ["1", "2", "3"])
17+
18+
os.environ["SW_ENABLE_BLOB_CACHE"] = "false"
19+
cloud_blob_cache.init()
20+
iter = cloud_blob_cache.replace_url("https://t/other?a=1", True)
21+
for _ in range(10):
22+
self.assertEqual(next(iter), "https://t/other?a=1")
23+
24+
cloud_blob_cache._servers = None
25+
os.environ["SW_ENABLE_BLOB_CACHE"] = "true"
1626
cloud_blob_cache.init()
1727
iter = cloud_blob_cache.replace_url("https://t/other?a=1", True)
1828
for _ in range(10):

0 commit comments

Comments
 (0)