Skip to content

Conversation

@ommistry2914
Copy link

  • Add wait_for_database_online helper methods to KnowledgeBaseResource and AsyncKnowledgeBaseResource so caller can wait for the knowledge base database to reach ONLINE without writing their own polling loops.

  • New methods :

       - KnowledgeBasesResources.wait_for_database_online(uuid,*,timeout=600,interval=5,raise_on_failed=True)
       - AsyncKnowledgeBaseResource.wait_for_database_online(uuid,*,timeout=600,interval=5,raise_on_failed=True)
    
  • Behavior

       - Polls retrieve(uuid) until database_status == "ONLINE"
       - Treats "UNHEALTHY" and "DECOMMISSIONED" as terminal failed states (raises RuntimeError when raise_on_failed=True).
       - Raises TimeoutError if timeout is exceeded.
       - Uses _sleep(interval) / await_sleep(interval) to avoid blocking.
    
  • Example
    - Sync
    client = Gradient(...) kb = client.knowledge_bases.wait_for_database_online("kb-uuid", timeout=600, interval=5)

       - Async:
             `async_client = AsyncGradient(...)
              kb = await async_client.knowledge_bases.wait_for_database_online("kb-uuid", timeout=600, interval=5)`
    

fixes #42

@bbatha
Copy link
Collaborator

bbatha commented Oct 22, 2025

Closing as a dupe of #49

@bbatha bbatha closed this Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a helper function to poll for knowledge base database creation

2 participants