Skip to content

Conversation

@srikanthbachala20
Copy link
Contributor

This pull request introduces a validation mechanism to the model loading process in clarifai/client/model.py, improving reliability during model initialization. The most important changes are:

Model Initialization Enhancements:

  • The __init__ method now calls self.load_info(validate=True) to ensure model information is validated when an instance is created.

Model Info Loading Improvements:

  • The load_info method signature is updated to accept a validate boolean parameter, allowing for conditional validation during the model info loading process.
  • The logic inside load_info is modified so that if validate is False, it processes and stores model information as before; otherwise, it skips this step, focusing on validation.

@srikanthbachala20 srikanthbachala20 requested review from a team and Copilot November 3, 2025 07:59
Copy link
Contributor

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 adds validation functionality to the Model.__init__() method by calling load_info(validate=True) during initialization. The change validates that a model exists when a Model object is created, without loading the full model information into self.kwargs and self.model_info.

Key Changes

  • Added a validate parameter to the load_info() method that skips loading model details when set to True
  • Added a call to load_info(validate=True) in the Model.__init__() method to validate model existence during initialization
Comments suppressed due to low confidence (1)

clarifai/client/model.py:1260

  • The new validation behavior introduced by calling load_info(validate=True) during initialization lacks test coverage. Specifically, there are no tests verifying that: (1) an exception is raised when initializing a Model with a non-existent model_id, (2) the validate parameter prevents loading model details, or (3) the existing test test_model_load_info still passes with the new initialization behavior. Add tests to cover these scenarios.
            self.load_info()

Copy link
Contributor

@mogith-pn mogith-pn left a comment

Choose a reason for hiding this comment

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

Just made one comment.

@github-actions
Copy link

github-actions bot commented Nov 3, 2025

Code Coverage

Package Line Rate Health
clarifai 45%
clarifai.cli 44%
clarifai.cli.templates 33%
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 52%
clarifai.runners.models 59%
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 60%
clarifai.utils.evaluation 67%
clarifai.workflows 95%
Summary 62% (8213 / 13330)

Minimum allowed line rate is 50%

@srikanthbachala20 srikanthbachala20 merged commit 872d39f into master Nov 3, 2025
12 checks passed
@srikanthbachala20 srikanthbachala20 deleted the PR-941-Non-Existent-Models-Handling branch November 3, 2025 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants