Skip to content

Conversation

mogith-pn
Copy link
Contributor

@mogith-pn mogith-pn commented Oct 10, 2025

Asynchronous Client Update

  • Added an async_client property to the Model class, which initializes and returns a ModelClient instance configured with an async stub. This allows separation between synchronous and asynchronous client operations.

  • Updated asynchronous methods (async_predict, async_generate, async_stream) to use self.async_client instead of self.client, ensuring proper usage of async stubs for async operations. [1] [2] [3]

  • Modified the __getattr__ method to delegate calls to async methods (those starting with async_) to the async_client, while other methods continue to use the regular client. This ensures method calls are routed to the appropriate client instance.

  • Added the _async_client attribute to the class initialization to store the async client instance, mirroring the existing _client attribute for synchronous operations.

@mogith-pn mogith-pn requested a review from Copilot October 10, 2025 10:52
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes asynchronous client initialization in the Model class by introducing proper separation between synchronous and asynchronous client instances. The changes ensure that async operations use dedicated async clients with proper stub configurations.

Key changes:

  • Added a new async_client property that creates a dedicated async client instance
  • Updated all async methods to use the new async client instead of the synchronous client
  • Modified attribute delegation to route async methods to the appropriate client

@mogith-pn mogith-pn requested a review from zeiler October 10, 2025 11:07
Copy link

Code Coverage

Package Line Rate Health
clarifai 43%
clarifai.cli 44%
clarifai.cli.templates 36%
clarifai.client 67%
clarifai.client.auth 67%
clarifai.constants 100%
clarifai.datasets 100%
clarifai.datasets.export 80%
clarifai.datasets.upload 75%
clarifai.datasets.upload.loaders 37%
clarifai.models 100%
clarifai.modules 0%
clarifai.rag 72%
clarifai.runners 53%
clarifai.runners.models 58%
clarifai.runners.pipeline_steps 41%
clarifai.runners.pipelines 70%
clarifai.runners.utils 63%
clarifai.runners.utils.data_types 72%
clarifai.schema 100%
clarifai.urls 60%
clarifai.utils 59%
clarifai.utils.evaluation 67%
clarifai.workflows 95%
Summary 61% (8083 / 13166)

Minimum allowed line rate is 50%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant