refactor(standalone): 收敛 _STANDALONE 判断到 standalone_proxy 单一来源
各模块不再各自读 os.environ,统一从 standalone_proxy._STANDALONE 导入, 环境变量只在一处决定模式,减少散落的重复逻辑。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -20,7 +20,8 @@ from fastapi.middleware.cors import CORSMiddleware
|
|||||||
from fastapi.responses import FileResponse, JSONResponse
|
from fastapi.responses import FileResponse, JSONResponse
|
||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
|
|
||||||
_STANDALONE = os.environ.get("KILOSTAR_MODE", "distributed") == "standalone"
|
from kilostar.utils.standalone_proxy import _STANDALONE
|
||||||
|
|
||||||
if not _STANDALONE:
|
if not _STANDALONE:
|
||||||
from ray import serve
|
from ray import serve
|
||||||
|
|
||||||
|
|||||||
@@ -12,11 +12,9 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import os
|
|
||||||
from typing import Any, Dict, List, Optional, Tuple
|
from typing import Any, Dict, List, Optional, Tuple
|
||||||
from kilostar.utils.standalone_proxy import actor_class
|
from kilostar.utils.standalone_proxy import actor_class, _STANDALONE
|
||||||
|
|
||||||
_STANDALONE = os.environ.get("KILOSTAR_MODE", "distributed") == "standalone"
|
|
||||||
if not _STANDALONE:
|
if not _STANDALONE:
|
||||||
import ray
|
import ray
|
||||||
|
|
||||||
|
|||||||
@@ -30,11 +30,11 @@ GSM 仍然是 source of truth + 写入串行化器,但读路径解耦:
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import os
|
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from typing import Any, Callable, Dict, List, Optional, Tuple
|
from typing import Any, Callable, Dict, List, Optional, Tuple
|
||||||
|
|
||||||
_STANDALONE = os.environ.get("KILOSTAR_MODE", "distributed") == "standalone"
|
from kilostar.utils.standalone_proxy import _STANDALONE
|
||||||
|
|
||||||
if not _STANDALONE:
|
if not _STANDALONE:
|
||||||
import ray
|
import ray
|
||||||
|
|
||||||
|
|||||||
@@ -11,12 +11,11 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
import os
|
|
||||||
import time
|
import time
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
from typing import Any, Dict
|
from typing import Any, Dict
|
||||||
|
|
||||||
_STANDALONE = os.environ.get("KILOSTAR_MODE", "distributed") == "standalone"
|
from kilostar.utils.standalone_proxy import _STANDALONE
|
||||||
|
|
||||||
if not _STANDALONE:
|
if not _STANDALONE:
|
||||||
import ray
|
import ray
|
||||||
|
|||||||
@@ -12,14 +12,12 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import os
|
|
||||||
import time
|
import time
|
||||||
import asyncio
|
import asyncio
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from kilostar.utils.standalone_proxy import actor_class
|
from kilostar.utils.standalone_proxy import actor_class, _STANDALONE
|
||||||
from kilostar.utils.ray_hook import ray_actor_hook
|
from kilostar.utils.ray_hook import ray_actor_hook
|
||||||
|
|
||||||
_STANDALONE = os.environ.get("KILOSTAR_MODE", "distributed") == "standalone"
|
|
||||||
if _STANDALONE:
|
if _STANDALONE:
|
||||||
from asyncio import Queue
|
from asyncio import Queue
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user