From 7ffc4f418146ad50c78d84810fc1adf7f6725ae5 Mon Sep 17 00:00:00 2001 From: hammadb Date: Mon, 13 Jan 2025 16:51:24 -0800 Subject: [PATCH] remove circ --- chromadb/config.py | 23 ++++++++++++++++--- .../impl/distributed/segment_directory.py | 21 +---------------- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/chromadb/config.py b/chromadb/config.py index fda815cc770..a773c698737 100644 --- a/chromadb/config.py +++ b/chromadb/config.py @@ -12,9 +12,6 @@ from typing_extensions import Literal import platform -from chromadb.segment.impl.distributed.segment_directory import RoutingMode - - in_pydantic_v2 = False try: from pydantic import BaseSettings @@ -100,6 +97,26 @@ class APIVersion(str, Enum): V2 = "/api/v2" +# NOTE(hammadb) 1/13/2024 - This has to be in config.py instead of being localized to the module +# that uses it because of a circular import issue. This is a temporary solution until we can +# refactor the code to remove the circular import. +class RoutingMode(Enum): + """ + Routing mode for the segment directory + + node - Assign based on the node name, used in production with multi-node settings with the assumption that + there is one query service pod per node. This is useful for when there is a disk based cache on the + node that we want to route to. + + id - Assign based on the member id, used in development and testing environments where the node name is not + guaranteed to be unique. (I.e a local development kubernetes env). Or when there are multiple query service + pods per node. + """ + + NODE = "node" + ID = "id" + + class Settings(BaseSettings): # type: ignore # ============== # Generic config diff --git a/chromadb/segment/impl/distributed/segment_directory.py b/chromadb/segment/impl/distributed/segment_directory.py index e9f18356116..13d2ef062e0 100644 --- a/chromadb/segment/impl/distributed/segment_directory.py +++ b/chromadb/segment/impl/distributed/segment_directory.py @@ -1,4 +1,3 @@ -from enum import Enum import threading import time from typing import Any, Callable, Dict, Optional, cast @@ -6,8 +5,7 @@ from kubernetes import client, config, watch from kubernetes.client.rest import ApiException from overrides import EnforceOverrides, override - -from chromadb.config import System +from chromadb.config import RoutingMode, System from chromadb.segment.distributed import ( Member, Memberlist, @@ -222,23 +220,6 @@ def _notify(self, memberlist: Memberlist) -> None: callback(memberlist) -class RoutingMode(Enum): - """ - Routing mode for the segment directory - - node - Assign based on the node name, used in production with multi-node settings with the assumption that - there is one query service pod per node. This is useful for when there is a disk based cache on the - node that we want to route to. - - id - Assign based on the member id, used in development and testing environments where the node name is not - guaranteed to be unique. (I.e a local development kubernetes env). Or when there are multiple query service - pods per node. - """ - - NODE = "node" - ID = "id" - - class RendezvousHashSegmentDirectory(SegmentDirectory, EnforceOverrides): _memberlist_provider: MemberlistProvider _curr_memberlist_mutex: threading.Lock