Skip to content
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

[Bug]: AttributeError: 'AdminClient' object has no attribute 'list_databases' #3806

Open
hassankhaw opened this issue Feb 18, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@hassankhaw
Copy link

hassankhaw commented Feb 18, 2025

What happened?

Not sure if it's a bug or bad code on my part.

In my Vector DB I am keeping customer data separate by assigning a database to each customer, where a database will have all the customer's collections. But, writing a simple method to fetch the existing databases in a tenant, I am getting the following error:
AttributeError: 'AdminClient' object has no attribute 'list_databases'

VS Code IntelliSense shows the list_databases() as one of the available methods:
Path: venv/lib/python3.11/site-packages/chromadb/api/init.py

class AdminAPI(ABC):
@abstractmethod
    def list_databases(
        self,
        limit: Optional[int] = None,
        offset: Optional[int] = None,
        tenant: str = DEFAULT_TENANT,
    ) -> Sequence[Database]:
        """List all databases for a tenant. Raises an error if the tenant does not exist.

        Args:
            tenant: The tenant to list databases for.

        """
        pass 

However, when I dump/print the value of the AdminClient object, I don't see list_databases() as one of the available methods._

def load_customers():
    # Use AdminClient to get the list of databases
    admin_client = create_chroma_admin_client()
    st.write(admin_client)  ----------------------> output attached in log
    databases = admin_client.list_databases(tenant=DEFAULT_TENANT) ----------> causes error
    return {db['name']: db['name'] for db in databases}

def create_chroma_admin_client():
    """Creates and returns a ChromaDB AdminClient."""
    config = load_config()
    adminClient= chromadb.AdminClient(Settings(
        chroma_api_impl="chromadb.api.fastapi.FastAPI",
        chroma_server_host=config['chromadb_host'],
        chroma_server_http_port=int(config['chromadb_port']),
    ))
    return adminClient

def main():
    st.title("Customer Management")
    # List Customers
    customers = load_customers()
    st.subheader("Existing Customers")
    if customers:
        customer_names = list(customers.keys())
        customer_table = [{"Customer Name": name, "Database ID": customers[name]} for name in customer_names]
        st.dataframe(customer_table, hide_index=True, use_container_width=True)
    else:
        st.write("No clients found.")

Versions

Chroma v0.6.3, WSL2 (Ubuntu) on Windows 11
Chroma DB running in Docker on port 8000

Relevant log output

main() 
**AdminClient** chromadb.api.client.AdminClient(settings: chromadb.config.Settings = Settings(environment='', chroma_api_impl='chromadb.api.segment.SegmentAPI', chroma_server_nofile=None, chroma_server_thread_pool_size=40, tenant_id='default', topic_namespace='default', chroma_server_host=None, chroma_server_headers=None, chroma_server_http_port=None, chroma_server_ssl_enabled=False, chroma_server_ssl_verify=None, chroma_server_api_default_path=<APIVersion.V2: '/api/v2'>, chroma_server_cors_allow_origins=[], is_persistent=False, persist_directory='./chroma', chroma_memory_limit_bytes=0, chroma_segment_cache_policy=None, allow_reset=False, chroma_auth_token_transport_header=None, chroma_client_auth_provider=None, chroma_client_auth_credentials=None, chroma_server_auth_ignore_paths={'APIVersion.V2': ['GET'], 'APIVersion.V2/heartbeat': ['GET'], 'APIVersion.V2/version': ['GET'], 'APIVersion.V1': ['GET'], 'APIVersion.V1/heartbeat': ['GET'], 'APIVersion.V1/version': ['GET']}, chroma_overwrite_singleton_tenant_database_access_from_auth=False, chroma_server_authn_provider=None, chroma_server_authn_credentials=None, chroma_server_authn_credentials_file=None, chroma_server_authz_provider=None, chroma_server_authz_config=None, chroma_server_authz_config_file=None, chroma_product_telemetry_impl='chromadb.telemetry.product.posthog.Posthog', chroma_telemetry_impl='chromadb.telemetry.product.posthog.Posthog', anonymized_telemetry=True, chroma_otel_collection_endpoint='', chroma_otel_service_name='chromadb', chroma_otel_collection_headers={}, chroma_otel_granularity=None, migrations='apply', migrations_hash_algorithm='md5', chroma_segment_directory_impl='chromadb.segment.impl.distributed.segment_directory.RendezvousHashSegmentDirectory', chroma_memberlist_provider_impl='chromadb.segment.impl.distributed.segment_directory.CustomResourceMemberlistProvider', worker_memberlist_name='query-service-memberlist', chroma_server_grpc_port=None, chroma_sysdb_impl='chromadb.db.impl.sqlite.SqliteDB', chroma_producer_impl='chromadb.db.impl.sqlite.SqliteDB', chroma_consumer_impl='chromadb.db.impl.sqlite.SqliteDB', chroma_segment_manager_impl='chromadb.segment.impl.manager.local.LocalSegmentManager', chroma_executor_impl='chromadb.execution.executor.local.LocalExecutor', chroma_quota_provider_impl=None, chroma_rate_limiting_provider_impl=None, chroma_quota_enforcer_impl='chromadb.quota.simple_quota_enforcer.SimpleQuotaEnforcer', chroma_rate_limit_enforcer_impl='chromadb.rate_limit.simple_rate_limit.SimpleRateLimitEnforcer', chroma_logservice_request_timeout_seconds=3, chroma_sysdb_request_timeout_seconds=3, chroma_query_request_timeout_seconds=60, chroma_db_impl=None, chroma_collection_assignment_policy_impl='chromadb.ingest.impl.simple_policy.SimpleAssignmentPolicy', chroma_coordinator_host='localhost', chroma_logservice_host='localhost', chroma_logservice_port=50052)) -> None

**Helper class that provides a standard way to create an ABC using inheritance. **

**clear_system_cache** function	No docs available
**create_database** method	Create a new database. Raises an error if the database already exists.
**create_tenant** method	Create a new tenant. Raises an error if the tenant already exists.
**from_system** method	Create a client from an existing system. This is useful for testing and debugging.
**get_database** method	Get a database. Raises an error if the database does not exist.
**get_tenant** method	Get a tenant. Raises an error if the tenant does not exist.

**AttributeError: 'AdminClient' object has no attribute 'list_databases'**

Traceback:

File ".pyenv/versions/3.11.9/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/exec_code.py", line 88, in exec_func_with_error_handling
    result = func()
             ^^^^^^
File ".pyenv/versions/3.11.9/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 579, in code_to_exec
    exec(code, module.__dict__)
File "client_management.py", line 139, in <module>
    main()
File "client_management.py", line 81, in main
    clients = load_clients()
              ^^^^^^^^^^^^^^
File "client_management.py", line 23, in load_clients
    databases = admin_client.list_databases(tenant=DEFAULT_TENANT)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@hassankhaw hassankhaw added the bug Something isn't working label Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant