clarifai 11.8.4__tar.gz → 11.8.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {clarifai-11.8.4/clarifai.egg-info → clarifai-11.8.5}/PKG-INFO +1 -1
 - clarifai-11.8.5/clarifai/__init__.py +1 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/client/model_client.py +58 -19
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/utils/method_signatures.py +9 -0
 - {clarifai-11.8.4 → clarifai-11.8.5/clarifai.egg-info}/PKG-INFO +1 -1
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai.egg-info/SOURCES.txt +2 -1
 - clarifai-11.8.5/tests/test_with_proto_feature.py +222 -0
 - clarifai-11.8.4/clarifai/__init__.py +0 -1
 - {clarifai-11.8.4 → clarifai-11.8.5}/LICENSE +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/MANIFEST.in +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/README.md +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/cli/README.md +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/cli/__init__.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/cli/__main__.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/cli/base.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/cli/compute_cluster.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/cli/deployment.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/cli/model.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/cli/nodepool.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/cli/pipeline.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/cli/pipeline_step.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/cli/templates/__init__.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/cli/templates/model_templates.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/cli/templates/pipeline_step_templates.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/cli/templates/pipeline_templates.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/cli.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/client/__init__.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/client/app.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/client/auth/__init__.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/client/auth/helper.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/client/auth/register.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/client/auth/stub.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/client/base.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/client/compute_cluster.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/client/dataset.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/client/deployment.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/client/input.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/client/lister.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/client/model.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/client/module.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/client/nodepool.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/client/pipeline.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/client/pipeline_step.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/client/runner.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/client/search.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/client/user.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/client/workflow.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/constants/base.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/constants/dataset.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/constants/input.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/constants/model.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/constants/rag.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/constants/search.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/constants/workflow.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/datasets/__init__.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/datasets/export/__init__.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/datasets/export/inputs_annotations.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/datasets/upload/__init__.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/datasets/upload/base.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/datasets/upload/features.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/datasets/upload/image.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/datasets/upload/loaders/README.md +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/datasets/upload/loaders/__init__.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/datasets/upload/loaders/coco_captions.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/datasets/upload/loaders/coco_detection.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/datasets/upload/loaders/imagenet_classification.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/datasets/upload/loaders/xview_detection.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/datasets/upload/multimodal.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/datasets/upload/text.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/datasets/upload/utils.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/errors.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/models/__init__.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/models/api.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/modules/README.md +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/modules/__init__.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/modules/css.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/modules/pages.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/modules/style.css +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/rag/__init__.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/rag/rag.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/rag/utils.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/__init__.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/dockerfile_template/Dockerfile.template +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/models/__init__.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/models/dummy_openai_model.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/models/mcp_class.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/models/model_builder.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/models/model_class.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/models/model_run_locally.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/models/model_runner.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/models/model_servicer.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/models/openai_class.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/models/visual_classifier_class.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/models/visual_detector_class.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/pipeline_steps/__init__.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/pipeline_steps/pipeline_step_builder.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/pipelines/__init__.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/pipelines/pipeline_builder.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/server.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/utils/__init__.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/utils/code_script.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/utils/const.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/utils/data_types/__init__.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/utils/data_types/data_types.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/utils/data_utils.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/utils/loader.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/utils/model_utils.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/utils/openai_convertor.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/utils/pipeline_validation.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/utils/serializers.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/utils/url_fetcher.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/schema/search.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/urls/helper.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/utils/__init__.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/utils/cli.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/utils/config.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/utils/constants.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/utils/evaluation/__init__.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/utils/evaluation/helpers.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/utils/evaluation/main.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/utils/evaluation/testset_annotation_parser.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/utils/hashing.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/utils/logging.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/utils/misc.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/utils/model_train.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/utils/protobuf.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/utils/secrets.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/versions.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/workflows/__init__.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/workflows/export.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/workflows/utils.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/workflows/validate.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai.egg-info/dependency_links.txt +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai.egg-info/entry_points.txt +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai.egg-info/requires.txt +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/clarifai.egg-info/top_level.txt +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/pyproject.toml +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/requirements.txt +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/setup.cfg +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/setup.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/tests/test_app.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/tests/test_async_stub.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/tests/test_auth.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/tests/test_data_upload.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/tests/test_eval.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/tests/test_list_models.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/tests/test_misc.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/tests/test_model_predict.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/tests/test_model_train.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/tests/test_modules.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/tests/test_pipeline_client.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/tests/test_rag.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/tests/test_search.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/tests/test_secrets.py +0 -0
 - {clarifai-11.8.4 → clarifai-11.8.5}/tests/test_stub.py +0 -0
 
| 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            __version__ = "11.8.5"
         
     | 
| 
         @@ -11,6 +11,7 @@ from clarifai.constants.model import MAX_MODEL_PREDICT_INPUTS 
     | 
|
| 
       11 
11 
     | 
    
         
             
            from clarifai.errors import UserError
         
     | 
| 
       12 
12 
     | 
    
         
             
            from clarifai.runners.utils import code_script, method_signatures
         
     | 
| 
       13 
13 
     | 
    
         
             
            from clarifai.runners.utils.method_signatures import (
         
     | 
| 
      
 14 
     | 
    
         
            +
                RESERVED_PARAM_WITH_PROTO,
         
     | 
| 
       14 
15 
     | 
    
         
             
                CompatibilitySerializer,
         
     | 
| 
       15 
16 
     | 
    
         
             
                deserialize,
         
     | 
| 
       16 
17 
     | 
    
         
             
                get_stream_from_signature,
         
     | 
| 
         @@ -204,6 +205,9 @@ class ModelClient: 
     | 
|
| 
       204 
205 
     | 
    
         | 
| 
       205 
206 
     | 
    
         
             
                        def bind_f(method_name, method_argnames, call_func, async_call_func):
         
     | 
| 
       206 
207 
     | 
    
         
             
                            def sync_f(*args, **kwargs):
         
     | 
| 
      
 208 
     | 
    
         
            +
                                # Extract with_proto parameter if present
         
     | 
| 
      
 209 
     | 
    
         
            +
                                with_proto = kwargs.pop(RESERVED_PARAM_WITH_PROTO, False)
         
     | 
| 
      
 210 
     | 
    
         
            +
             
     | 
| 
       207 
211 
     | 
    
         
             
                                if len(args) > len(method_argnames):
         
     | 
| 
       208 
212 
     | 
    
         
             
                                    raise TypeError(
         
     | 
| 
       209 
213 
     | 
    
         
             
                                        f"{method_name}() takes {len(method_argnames)} positional arguments but {len(args)} were given"
         
     | 
| 
         @@ -221,7 +225,7 @@ class ModelClient: 
     | 
|
| 
       221 
225 
     | 
    
         
             
                                    )
         
     | 
| 
       222 
226 
     | 
    
         
             
                                    if is_batch_input_valid and (not is_openai_chat_format(batch_inputs)):
         
     | 
| 
       223 
227 
     | 
    
         
             
                                        # If the batch input is valid, call the function with the batch inputs and the method name
         
     | 
| 
       224 
     | 
    
         
            -
                                        return call_func(batch_inputs, method_name)
         
     | 
| 
      
 228 
     | 
    
         
            +
                                        return call_func(batch_inputs, method_name, with_proto=with_proto)
         
     | 
| 
       225 
229 
     | 
    
         | 
| 
       226 
230 
     | 
    
         
             
                                for name, arg in zip(
         
     | 
| 
       227 
231 
     | 
    
         
             
                                    method_argnames, args
         
     | 
| 
         @@ -229,10 +233,13 @@ class ModelClient: 
     | 
|
| 
       229 
233 
     | 
    
         
             
                                    if name in kwargs:
         
     | 
| 
       230 
234 
     | 
    
         
             
                                        raise TypeError(f"Multiple values for argument {name}")
         
     | 
| 
       231 
235 
     | 
    
         
             
                                    kwargs[name] = arg
         
     | 
| 
       232 
     | 
    
         
            -
                                return call_func(kwargs, method_name)
         
     | 
| 
      
 236 
     | 
    
         
            +
                                return call_func(kwargs, method_name, with_proto=with_proto)
         
     | 
| 
       233 
237 
     | 
    
         | 
| 
       234 
238 
     | 
    
         
             
                            async def async_f(*args, **kwargs):
         
     | 
| 
       235 
239 
     | 
    
         
             
                                # Async version to call the async function
         
     | 
| 
      
 240 
     | 
    
         
            +
                                # Extract with_proto parameter if present
         
     | 
| 
      
 241 
     | 
    
         
            +
                                with_proto = kwargs.pop(RESERVED_PARAM_WITH_PROTO, False)
         
     | 
| 
      
 242 
     | 
    
         
            +
             
     | 
| 
       236 
243 
     | 
    
         
             
                                if len(args) > len(method_argnames):
         
     | 
| 
       237 
244 
     | 
    
         
             
                                    raise TypeError(
         
     | 
| 
       238 
245 
     | 
    
         
             
                                        f"{method_name}() takes {len(method_argnames)} positional arguments but {len(args)} were given"
         
     | 
| 
         @@ -249,7 +256,9 @@ class ModelClient: 
     | 
|
| 
       249 
256 
     | 
    
         
             
                                    )
         
     | 
| 
       250 
257 
     | 
    
         
             
                                    if is_batch_input_valid and (not is_openai_chat_format(batch_inputs)):
         
     | 
| 
       251 
258 
     | 
    
         
             
                                        # If the batch input is valid, call the function with the batch inputs and the method name
         
     | 
| 
       252 
     | 
    
         
            -
                                        return async_call_func( 
     | 
| 
      
 259 
     | 
    
         
            +
                                        return async_call_func(
         
     | 
| 
      
 260 
     | 
    
         
            +
                                            batch_inputs, method_name, with_proto=with_proto
         
     | 
| 
      
 261 
     | 
    
         
            +
                                        )
         
     | 
| 
       253 
262 
     | 
    
         | 
| 
       254 
263 
     | 
    
         
             
                                for name, arg in zip(
         
     | 
| 
       255 
264 
     | 
    
         
             
                                    method_argnames, args
         
     | 
| 
         @@ -258,7 +267,7 @@ class ModelClient: 
     | 
|
| 
       258 
267 
     | 
    
         
             
                                        raise TypeError(f"Multiple values for argument {name}")
         
     | 
| 
       259 
268 
     | 
    
         
             
                                    kwargs[name] = arg
         
     | 
| 
       260 
269 
     | 
    
         | 
| 
       261 
     | 
    
         
            -
                                return async_call_func(kwargs, method_name)
         
     | 
| 
      
 270 
     | 
    
         
            +
                                return async_call_func(kwargs, method_name, with_proto=with_proto)
         
     | 
| 
       262 
271 
     | 
    
         | 
| 
       263 
272 
     | 
    
         
             
                            class MethodWrapper:
         
     | 
| 
       264 
273 
     | 
    
         
             
                                def __call__(self, *args, **kwargs):
         
     | 
| 
         @@ -364,6 +373,7 @@ class ModelClient: 
     | 
|
| 
       364 
373 
     | 
    
         
             
                    self,
         
     | 
| 
       365 
374 
     | 
    
         
             
                    inputs,  # TODO set up functions according to fetched signatures?
         
     | 
| 
       366 
375 
     | 
    
         
             
                    method_name: str = 'predict',
         
     | 
| 
      
 376 
     | 
    
         
            +
                    with_proto: bool = False,
         
     | 
| 
       367 
377 
     | 
    
         
             
                ) -> Any:
         
     | 
| 
       368 
378 
     | 
    
         
             
                    input_signature = self._method_signatures[method_name].input_fields
         
     | 
| 
       369 
379 
     | 
    
         
             
                    output_signature = self._method_signatures[method_name].output_fields
         
     | 
| 
         @@ -385,9 +395,12 @@ class ModelClient: 
     | 
|
| 
       385 
395 
     | 
    
         
             
                    outputs = []
         
     | 
| 
       386 
396 
     | 
    
         
             
                    for output in response.outputs:
         
     | 
| 
       387 
397 
     | 
    
         
             
                        outputs.append(deserialize(output.data, output_signature, is_output=True))
         
     | 
| 
       388 
     | 
    
         
            -
             
     | 
| 
       389 
     | 
    
         
            -
             
     | 
| 
       390 
     | 
    
         
            -
             
     | 
| 
      
 398 
     | 
    
         
            +
             
     | 
| 
      
 399 
     | 
    
         
            +
                    result = outputs if batch_input else outputs[0]
         
     | 
| 
      
 400 
     | 
    
         
            +
             
     | 
| 
      
 401 
     | 
    
         
            +
                    if with_proto:
         
     | 
| 
      
 402 
     | 
    
         
            +
                        return result, response
         
     | 
| 
      
 403 
     | 
    
         
            +
                    return result
         
     | 
| 
       391 
404 
     | 
    
         | 
| 
       392 
405 
     | 
    
         
             
                def _predict_by_proto(
         
     | 
| 
       393 
406 
     | 
    
         
             
                    self,
         
     | 
| 
         @@ -448,15 +461,17 @@ class ModelClient: 
     | 
|
| 
       448 
461 
     | 
    
         
             
                    self,
         
     | 
| 
       449 
462 
     | 
    
         
             
                    inputs,
         
     | 
| 
       450 
463 
     | 
    
         
             
                    method_name: str = 'predict',
         
     | 
| 
      
 464 
     | 
    
         
            +
                    with_proto: bool = False,
         
     | 
| 
       451 
465 
     | 
    
         
             
                ) -> Any:
         
     | 
| 
       452 
466 
     | 
    
         
             
                    """Asynchronously process inputs and make predictions.
         
     | 
| 
       453 
467 
     | 
    
         | 
| 
       454 
468 
     | 
    
         
             
                    Args:
         
     | 
| 
       455 
469 
     | 
    
         
             
                        inputs: Input data to process
         
     | 
| 
       456 
470 
     | 
    
         
             
                        method_name (str): Name of the method to call
         
     | 
| 
      
 471 
     | 
    
         
            +
                        with_proto (bool): If True, return both the processed result and the raw protobuf response
         
     | 
| 
       457 
472 
     | 
    
         | 
| 
       458 
473 
     | 
    
         
             
                    Returns:
         
     | 
| 
       459 
     | 
    
         
            -
                        Processed prediction results
         
     | 
| 
      
 474 
     | 
    
         
            +
                        Processed prediction results, optionally with protobuf response
         
     | 
| 
       460 
475 
     | 
    
         
             
                    """
         
     | 
| 
       461 
476 
     | 
    
         
             
                    # method_name is set to 'predict' by default, this is because to replicate the input and output signature behaviour of sync to async predict.
         
     | 
| 
       462 
477 
     | 
    
         
             
                    input_signature = self._method_signatures[method_name].input_fields
         
     | 
| 
         @@ -477,7 +492,11 @@ class ModelClient: 
     | 
|
| 
       477 
492 
     | 
    
         
             
                    for output in response.outputs:
         
     | 
| 
       478 
493 
     | 
    
         
             
                        outputs.append(deserialize(output.data, output_signature, is_output=True))
         
     | 
| 
       479 
494 
     | 
    
         | 
| 
       480 
     | 
    
         
            -
                     
     | 
| 
      
 495 
     | 
    
         
            +
                    result = outputs if batch_input else outputs[0]
         
     | 
| 
      
 496 
     | 
    
         
            +
             
     | 
| 
      
 497 
     | 
    
         
            +
                    if with_proto:
         
     | 
| 
      
 498 
     | 
    
         
            +
                        return result, response
         
     | 
| 
      
 499 
     | 
    
         
            +
                    return result
         
     | 
| 
       481 
500 
     | 
    
         | 
| 
       482 
501 
     | 
    
         
             
                async def _async_predict_by_proto(
         
     | 
| 
       483 
502 
     | 
    
         
             
                    self,
         
     | 
| 
         @@ -551,6 +570,7 @@ class ModelClient: 
     | 
|
| 
       551 
570 
     | 
    
         
             
                    self,
         
     | 
| 
       552 
571 
     | 
    
         
             
                    inputs,  # TODO set up functions according to fetched signatures?
         
     | 
| 
       553 
572 
     | 
    
         
             
                    method_name: str = 'generate',
         
     | 
| 
      
 573 
     | 
    
         
            +
                    with_proto: bool = False,
         
     | 
| 
       554 
574 
     | 
    
         
             
                ) -> Any:
         
     | 
| 
       555 
575 
     | 
    
         
             
                    input_signature = self._method_signatures[method_name].input_fields
         
     | 
| 
       556 
576 
     | 
    
         
             
                    output_signature = self._method_signatures[method_name].output_fields
         
     | 
| 
         @@ -572,10 +592,13 @@ class ModelClient: 
     | 
|
| 
       572 
592 
     | 
    
         
             
                        outputs = []
         
     | 
| 
       573 
593 
     | 
    
         
             
                        for output in response.outputs:
         
     | 
| 
       574 
594 
     | 
    
         
             
                            outputs.append(deserialize(output.data, output_signature, is_output=True))
         
     | 
| 
       575 
     | 
    
         
            -
             
     | 
| 
       576 
     | 
    
         
            -
             
     | 
| 
      
 595 
     | 
    
         
            +
             
     | 
| 
      
 596 
     | 
    
         
            +
                        result = outputs if batch_input else outputs[0]
         
     | 
| 
      
 597 
     | 
    
         
            +
             
     | 
| 
      
 598 
     | 
    
         
            +
                        if with_proto:
         
     | 
| 
      
 599 
     | 
    
         
            +
                            yield result, response
         
     | 
| 
       577 
600 
     | 
    
         
             
                        else:
         
     | 
| 
       578 
     | 
    
         
            -
                            yield  
     | 
| 
      
 601 
     | 
    
         
            +
                            yield result
         
     | 
| 
       579 
602 
     | 
    
         | 
| 
       580 
603 
     | 
    
         
             
                def _generate_by_proto(
         
     | 
| 
       581 
604 
     | 
    
         
             
                    self,
         
     | 
| 
         @@ -641,6 +664,7 @@ class ModelClient: 
     | 
|
| 
       641 
664 
     | 
    
         
             
                    self,
         
     | 
| 
       642 
665 
     | 
    
         
             
                    inputs,
         
     | 
| 
       643 
666 
     | 
    
         
             
                    method_name: str = 'generate',
         
     | 
| 
      
 667 
     | 
    
         
            +
                    with_proto: bool = False,
         
     | 
| 
       644 
668 
     | 
    
         
             
                ) -> Any:
         
     | 
| 
       645 
669 
     | 
    
         
             
                    # method_name is set to 'generate' by default, this is because to replicate the input and output signature behaviour of sync to async generate.
         
     | 
| 
       646 
670 
     | 
    
         
             
                    input_signature = self._method_signatures[method_name].input_fields
         
     | 
| 
         @@ -654,18 +678,21 @@ class ModelClient: 
     | 
|
| 
       654 
678 
     | 
    
         
             
                    proto_inputs = []
         
     | 
| 
       655 
679 
     | 
    
         
             
                    for input in inputs:
         
     | 
| 
       656 
680 
     | 
    
         
             
                        proto = resources_pb2.Input()
         
     | 
| 
       657 
     | 
    
         
            -
             
     | 
| 
       658 
     | 
    
         
            -
             
     | 
| 
      
 681 
     | 
    
         
            +
                        serialize(input, input_signature, proto.data)
         
     | 
| 
      
 682 
     | 
    
         
            +
                        proto_inputs.append(proto)
         
     | 
| 
       659 
683 
     | 
    
         
             
                    response_stream = self._async_generate_by_proto(proto_inputs, method_name)
         
     | 
| 
       660 
684 
     | 
    
         | 
| 
       661 
685 
     | 
    
         
             
                    async for response in response_stream:
         
     | 
| 
       662 
686 
     | 
    
         
             
                        outputs = []
         
     | 
| 
       663 
687 
     | 
    
         
             
                        for output in response.outputs:
         
     | 
| 
       664 
688 
     | 
    
         
             
                            outputs.append(deserialize(output.data, output_signature, is_output=True))
         
     | 
| 
       665 
     | 
    
         
            -
             
     | 
| 
       666 
     | 
    
         
            -
             
     | 
| 
      
 689 
     | 
    
         
            +
             
     | 
| 
      
 690 
     | 
    
         
            +
                        result = outputs if batch_input else outputs[0]
         
     | 
| 
      
 691 
     | 
    
         
            +
             
     | 
| 
      
 692 
     | 
    
         
            +
                        if with_proto:
         
     | 
| 
      
 693 
     | 
    
         
            +
                            yield result, response
         
     | 
| 
       667 
694 
     | 
    
         
             
                        else:
         
     | 
| 
       668 
     | 
    
         
            -
                            yield  
     | 
| 
      
 695 
     | 
    
         
            +
                            yield result
         
     | 
| 
       669 
696 
     | 
    
         | 
| 
       670 
697 
     | 
    
         
             
                async def _async_generate_by_proto(
         
     | 
| 
       671 
698 
     | 
    
         
             
                    self,
         
     | 
| 
         @@ -734,6 +761,7 @@ class ModelClient: 
     | 
|
| 
       734 
761 
     | 
    
         
             
                    self,
         
     | 
| 
       735 
762 
     | 
    
         
             
                    inputs,
         
     | 
| 
       736 
763 
     | 
    
         
             
                    method_name: str = 'stream',
         
     | 
| 
      
 764 
     | 
    
         
            +
                    with_proto: bool = False,
         
     | 
| 
       737 
765 
     | 
    
         
             
                ) -> Any:
         
     | 
| 
       738 
766 
     | 
    
         
             
                    input_signature = self._method_signatures[method_name].input_fields
         
     | 
| 
       739 
767 
     | 
    
         
             
                    output_signature = self._method_signatures[method_name].output_fields
         
     | 
| 
         @@ -775,7 +803,12 @@ class ModelClient: 
     | 
|
| 
       775 
803 
     | 
    
         | 
| 
       776 
804 
     | 
    
         
             
                    for response in response_stream:
         
     | 
| 
       777 
805 
     | 
    
         
             
                        assert len(response.outputs) == 1, 'streaming methods must have exactly one output'
         
     | 
| 
       778 
     | 
    
         
            -
                         
     | 
| 
      
 806 
     | 
    
         
            +
                        result = deserialize(response.outputs[0].data, output_signature, is_output=True)
         
     | 
| 
      
 807 
     | 
    
         
            +
             
     | 
| 
      
 808 
     | 
    
         
            +
                        if with_proto:
         
     | 
| 
      
 809 
     | 
    
         
            +
                            yield result, response
         
     | 
| 
      
 810 
     | 
    
         
            +
                        else:
         
     | 
| 
      
 811 
     | 
    
         
            +
                            yield result
         
     | 
| 
       779 
812 
     | 
    
         | 
| 
       780 
813 
     | 
    
         
             
                def _req_iterator(
         
     | 
| 
       781 
814 
     | 
    
         
             
                    self,
         
     | 
| 
         @@ -843,6 +876,7 @@ class ModelClient: 
     | 
|
| 
       843 
876 
     | 
    
         
             
                    self,
         
     | 
| 
       844 
877 
     | 
    
         
             
                    inputs,
         
     | 
| 
       845 
878 
     | 
    
         
             
                    method_name: str = 'stream',
         
     | 
| 
      
 879 
     | 
    
         
            +
                    with_proto: bool = False,
         
     | 
| 
       846 
880 
     | 
    
         
             
                ) -> Any:
         
     | 
| 
       847 
881 
     | 
    
         
             
                    # method_name is set to 'stream' by default, this is because to replicate the input and output signature behaviour of sync to async stream.
         
     | 
| 
       848 
882 
     | 
    
         
             
                    input_signature = self._method_signatures[method_name].input_fields
         
     | 
| 
         @@ -885,7 +919,12 @@ class ModelClient: 
     | 
|
| 
       885 
919 
     | 
    
         | 
| 
       886 
920 
     | 
    
         
             
                    async for response in response_stream:
         
     | 
| 
       887 
921 
     | 
    
         
             
                        assert len(response.outputs) == 1, 'streaming methods must have exactly one output'
         
     | 
| 
       888 
     | 
    
         
            -
                         
     | 
| 
      
 922 
     | 
    
         
            +
                        result = deserialize(response.outputs[0].data, output_signature, is_output=True)
         
     | 
| 
      
 923 
     | 
    
         
            +
             
     | 
| 
      
 924 
     | 
    
         
            +
                        if with_proto:
         
     | 
| 
      
 925 
     | 
    
         
            +
                            yield result, response
         
     | 
| 
      
 926 
     | 
    
         
            +
                        else:
         
     | 
| 
      
 927 
     | 
    
         
            +
                            yield result
         
     | 
| 
       889 
928 
     | 
    
         | 
| 
       890 
929 
     | 
    
         
             
                async def _async_stream_by_proto(
         
     | 
| 
       891 
930 
     | 
    
         
             
                    self,
         
     | 
| 
         @@ -23,6 +23,9 @@ from clarifai.runners.utils.serializers import ( 
     | 
|
| 
       23 
23 
     | 
    
         
             
                TupleSerializer,
         
     | 
| 
       24 
24 
     | 
    
         
             
            )
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
      
 26 
     | 
    
         
            +
            # Reserved parameter name for protobuf response access
         
     | 
| 
      
 27 
     | 
    
         
            +
            RESERVED_PARAM_WITH_PROTO = 'with_proto'
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
       26 
29 
     | 
    
         | 
| 
       27 
30 
     | 
    
         
             
            def build_function_signature(func):
         
     | 
| 
       28 
31 
     | 
    
         
             
                '''
         
     | 
| 
         @@ -45,6 +48,12 @@ def build_function_signature(func): 
     | 
|
| 
       45 
48 
     | 
    
         
             
                input_sigs = []
         
     | 
| 
       46 
49 
     | 
    
         
             
                input_streaming = []
         
     | 
| 
       47 
50 
     | 
    
         
             
                for p in sig.parameters.values():
         
     | 
| 
      
 51 
     | 
    
         
            +
                    # Validate that user methods don't use reserved parameter names
         
     | 
| 
      
 52 
     | 
    
         
            +
                    if p.name == RESERVED_PARAM_WITH_PROTO:
         
     | 
| 
      
 53 
     | 
    
         
            +
                        raise ValueError(
         
     | 
| 
      
 54 
     | 
    
         
            +
                            f"Parameter name '{RESERVED_PARAM_WITH_PROTO}' is reserved and cannot be used in model methods. "
         
     | 
| 
      
 55 
     | 
    
         
            +
                            f"This parameter is automatically added by the framework to provide access to protobuf responses."
         
     | 
| 
      
 56 
     | 
    
         
            +
                        )
         
     | 
| 
       48 
57 
     | 
    
         
             
                    model_type_field, _, streaming = build_variable_signature(p.name, p.annotation, p.default)
         
     | 
| 
       49 
58 
     | 
    
         
             
                    input_sigs.append(model_type_field)
         
     | 
| 
       50 
59 
     | 
    
         
             
                    input_streaming.append(streaming)
         
     | 
| 
         @@ -0,0 +1,222 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            """
         
     | 
| 
      
 2 
     | 
    
         
            +
            Tests for the with_proto feature in pythonic models
         
     | 
| 
      
 3 
     | 
    
         
            +
            """
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            import unittest
         
     | 
| 
      
 6 
     | 
    
         
            +
            from unittest.mock import Mock, patch
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            from clarifai_grpc.grpc.api import service_pb2
         
     | 
| 
      
 9 
     | 
    
         
            +
            from clarifai_grpc.grpc.api.status import status_code_pb2
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            from clarifai.client.model_client import ModelClient
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            class TestWithProtoFeature(unittest.TestCase):
         
     | 
| 
      
 15 
     | 
    
         
            +
                """Test class for with_proto functionality"""
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                def test_predict_with_proto_parameter_exists(self):
         
     | 
| 
      
 18 
     | 
    
         
            +
                    """Test that _predict method has with_proto parameter"""
         
     | 
| 
      
 19 
     | 
    
         
            +
                    import inspect
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                    sig = inspect.signature(ModelClient._predict)
         
     | 
| 
      
 22 
     | 
    
         
            +
                    self.assertIn('with_proto', sig.parameters)
         
     | 
| 
      
 23 
     | 
    
         
            +
                    self.assertIs(sig.parameters['with_proto'].default, False)
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                def test_generate_with_proto_parameter_exists(self):
         
     | 
| 
      
 26 
     | 
    
         
            +
                    """Test that _generate method has with_proto parameter"""
         
     | 
| 
      
 27 
     | 
    
         
            +
                    import inspect
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                    sig = inspect.signature(ModelClient._generate)
         
     | 
| 
      
 30 
     | 
    
         
            +
                    self.assertIn('with_proto', sig.parameters)
         
     | 
| 
      
 31 
     | 
    
         
            +
                    self.assertIs(sig.parameters['with_proto'].default, False)
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                def test_stream_with_proto_parameter_exists(self):
         
     | 
| 
      
 34 
     | 
    
         
            +
                    """Test that _stream method has with_proto parameter"""
         
     | 
| 
      
 35 
     | 
    
         
            +
                    import inspect
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                    sig = inspect.signature(ModelClient._stream)
         
     | 
| 
      
 38 
     | 
    
         
            +
                    self.assertIn('with_proto', sig.parameters)
         
     | 
| 
      
 39 
     | 
    
         
            +
                    self.assertIs(sig.parameters['with_proto'].default, False)
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                def test_async_predict_with_proto_parameter_exists(self):
         
     | 
| 
      
 42 
     | 
    
         
            +
                    """Test that _async_predict method has with_proto parameter"""
         
     | 
| 
      
 43 
     | 
    
         
            +
                    import inspect
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                    sig = inspect.signature(ModelClient._async_predict)
         
     | 
| 
      
 46 
     | 
    
         
            +
                    self.assertIn('with_proto', sig.parameters)
         
     | 
| 
      
 47 
     | 
    
         
            +
                    self.assertIs(sig.parameters['with_proto'].default, False)
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                def test_async_generate_with_proto_parameter_exists(self):
         
     | 
| 
      
 50 
     | 
    
         
            +
                    """Test that _async_generate method has with_proto parameter"""
         
     | 
| 
      
 51 
     | 
    
         
            +
                    import inspect
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                    sig = inspect.signature(ModelClient._async_generate)
         
     | 
| 
      
 54 
     | 
    
         
            +
                    self.assertIn('with_proto', sig.parameters)
         
     | 
| 
      
 55 
     | 
    
         
            +
                    self.assertIs(sig.parameters['with_proto'].default, False)
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                def test_async_stream_with_proto_parameter_exists(self):
         
     | 
| 
      
 58 
     | 
    
         
            +
                    """Test that _async_stream method has with_proto parameter"""
         
     | 
| 
      
 59 
     | 
    
         
            +
                    import inspect
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                    sig = inspect.signature(ModelClient._async_stream)
         
     | 
| 
      
 62 
     | 
    
         
            +
                    self.assertIn('with_proto', sig.parameters)
         
     | 
| 
      
 63 
     | 
    
         
            +
                    self.assertIs(sig.parameters['with_proto'].default, False)
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                def test_with_proto_parameter_extraction(self):
         
     | 
| 
      
 66 
     | 
    
         
            +
                    """Test that with_proto parameter is correctly extracted from kwargs"""
         
     | 
| 
      
 67 
     | 
    
         
            +
                    # Test the parameter extraction logic used in bind_f
         
     | 
| 
      
 68 
     | 
    
         
            +
                    test_kwargs = {'param1': 'value1', 'with_proto': True, 'param2': 'value2'}
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
                    # Extract with_proto parameter like the code does
         
     | 
| 
      
 71 
     | 
    
         
            +
                    with_proto = test_kwargs.pop('with_proto', False)
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                    # Verify extraction worked correctly
         
     | 
| 
      
 74 
     | 
    
         
            +
                    self.assertIs(with_proto, True)
         
     | 
| 
      
 75 
     | 
    
         
            +
                    self.assertNotIn('with_proto', test_kwargs)
         
     | 
| 
      
 76 
     | 
    
         
            +
                    self.assertEqual(test_kwargs, {'param1': 'value1', 'param2': 'value2'})
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
                def test_with_proto_default_behavior(self):
         
     | 
| 
      
 79 
     | 
    
         
            +
                    """Test that with_proto defaults to False when not provided"""
         
     | 
| 
      
 80 
     | 
    
         
            +
                    test_kwargs = {'param1': 'value1', 'param2': 'value2'}
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
                    # Extract with_proto parameter with default
         
     | 
| 
      
 83 
     | 
    
         
            +
                    with_proto = test_kwargs.pop('with_proto', False)
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
                    # Verify default behavior
         
     | 
| 
      
 86 
     | 
    
         
            +
                    self.assertIs(with_proto, False)
         
     | 
| 
      
 87 
     | 
    
         
            +
                    self.assertEqual(test_kwargs, {'param1': 'value1', 'param2': 'value2'})
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
                @patch('clarifai.client.model_client.serialize')
         
     | 
| 
      
 90 
     | 
    
         
            +
                @patch('clarifai.client.model_client.deserialize')
         
     | 
| 
      
 91 
     | 
    
         
            +
                def test_predict_with_proto_false(self, mock_deserialize, mock_serialize):
         
     | 
| 
      
 92 
     | 
    
         
            +
                    """Test _predict method with with_proto=False returns only result"""
         
     | 
| 
      
 93 
     | 
    
         
            +
                    # Setup mocks
         
     | 
| 
      
 94 
     | 
    
         
            +
                    mock_deserialize.return_value = "test_result"
         
     | 
| 
      
 95 
     | 
    
         
            +
                    mock_serialize.return_value = None
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
                    # Create mock response
         
     | 
| 
      
 98 
     | 
    
         
            +
                    mock_response = service_pb2.MultiOutputResponse()
         
     | 
| 
      
 99 
     | 
    
         
            +
                    mock_response.status.code = status_code_pb2.SUCCESS
         
     | 
| 
      
 100 
     | 
    
         
            +
                    output = mock_response.outputs.add()
         
     | 
| 
      
 101 
     | 
    
         
            +
             
     | 
| 
      
 102 
     | 
    
         
            +
                    # Create mock stub
         
     | 
| 
      
 103 
     | 
    
         
            +
                    mock_stub = Mock()
         
     | 
| 
      
 104 
     | 
    
         
            +
                    mock_stub.PostModelOutputs.return_value = mock_response
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
                    # Create client with mock method signatures
         
     | 
| 
      
 107 
     | 
    
         
            +
                    request_template = service_pb2.PostModelOutputsRequest()
         
     | 
| 
      
 108 
     | 
    
         
            +
                    client = ModelClient(stub=mock_stub, request_template=request_template)
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
                    # Mock method signature
         
     | 
| 
      
 111 
     | 
    
         
            +
                    method_signature = Mock()
         
     | 
| 
      
 112 
     | 
    
         
            +
                    method_signature.input_fields = []
         
     | 
| 
      
 113 
     | 
    
         
            +
                    method_signature.output_fields = []
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
      
 115 
     | 
    
         
            +
                    client._method_signatures = {'predict': method_signature}
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
                    # Test with with_proto=False
         
     | 
| 
      
 118 
     | 
    
         
            +
                    result = client._predict({'text': 'test'}, 'predict', with_proto=False)
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
      
 120 
     | 
    
         
            +
                    # Should return only the result, not a tuple
         
     | 
| 
      
 121 
     | 
    
         
            +
                    self.assertEqual(result, "test_result")
         
     | 
| 
      
 122 
     | 
    
         
            +
                    self.assertNotIsInstance(result, tuple)
         
     | 
| 
      
 123 
     | 
    
         
            +
             
     | 
| 
      
 124 
     | 
    
         
            +
                @patch('clarifai.client.model_client.serialize')
         
     | 
| 
      
 125 
     | 
    
         
            +
                @patch('clarifai.client.model_client.deserialize')
         
     | 
| 
      
 126 
     | 
    
         
            +
                def test_predict_with_proto_true(self, mock_deserialize, mock_serialize):
         
     | 
| 
      
 127 
     | 
    
         
            +
                    """Test _predict method with with_proto=True returns (result, proto) tuple"""
         
     | 
| 
      
 128 
     | 
    
         
            +
                    # Setup mocks
         
     | 
| 
      
 129 
     | 
    
         
            +
                    mock_deserialize.return_value = "test_result"
         
     | 
| 
      
 130 
     | 
    
         
            +
                    mock_serialize.return_value = None
         
     | 
| 
      
 131 
     | 
    
         
            +
             
     | 
| 
      
 132 
     | 
    
         
            +
                    # Create mock response
         
     | 
| 
      
 133 
     | 
    
         
            +
                    mock_response = service_pb2.MultiOutputResponse()
         
     | 
| 
      
 134 
     | 
    
         
            +
                    mock_response.status.code = status_code_pb2.SUCCESS
         
     | 
| 
      
 135 
     | 
    
         
            +
                    output = mock_response.outputs.add()
         
     | 
| 
      
 136 
     | 
    
         
            +
             
     | 
| 
      
 137 
     | 
    
         
            +
                    # Create mock stub
         
     | 
| 
      
 138 
     | 
    
         
            +
                    mock_stub = Mock()
         
     | 
| 
      
 139 
     | 
    
         
            +
                    mock_stub.PostModelOutputs.return_value = mock_response
         
     | 
| 
      
 140 
     | 
    
         
            +
             
     | 
| 
      
 141 
     | 
    
         
            +
                    # Create client with mock method signatures
         
     | 
| 
      
 142 
     | 
    
         
            +
                    request_template = service_pb2.PostModelOutputsRequest()
         
     | 
| 
      
 143 
     | 
    
         
            +
                    client = ModelClient(stub=mock_stub, request_template=request_template)
         
     | 
| 
      
 144 
     | 
    
         
            +
             
     | 
| 
      
 145 
     | 
    
         
            +
                    # Mock method signature
         
     | 
| 
      
 146 
     | 
    
         
            +
                    method_signature = Mock()
         
     | 
| 
      
 147 
     | 
    
         
            +
                    method_signature.input_fields = []
         
     | 
| 
      
 148 
     | 
    
         
            +
                    method_signature.output_fields = []
         
     | 
| 
      
 149 
     | 
    
         
            +
             
     | 
| 
      
 150 
     | 
    
         
            +
                    client._method_signatures = {'predict': method_signature}
         
     | 
| 
      
 151 
     | 
    
         
            +
             
     | 
| 
      
 152 
     | 
    
         
            +
                    # Test with with_proto=True
         
     | 
| 
      
 153 
     | 
    
         
            +
                    result = client._predict({'text': 'test'}, 'predict', with_proto=True)
         
     | 
| 
      
 154 
     | 
    
         
            +
             
     | 
| 
      
 155 
     | 
    
         
            +
                    # Should return tuple (result, proto)
         
     | 
| 
      
 156 
     | 
    
         
            +
                    self.assertIsInstance(result, tuple)
         
     | 
| 
      
 157 
     | 
    
         
            +
                    self.assertEqual(len(result), 2)
         
     | 
| 
      
 158 
     | 
    
         
            +
                    self.assertEqual(result[0], "test_result")  # The deserialized result
         
     | 
| 
      
 159 
     | 
    
         
            +
                    self.assertEqual(result[1], mock_response)  # The proto response
         
     | 
| 
      
 160 
     | 
    
         
            +
             
     | 
| 
      
 161 
     | 
    
         
            +
                def test_backward_compatibility(self):
         
     | 
| 
      
 162 
     | 
    
         
            +
                    """Test that existing code without with_proto continues to work"""
         
     | 
| 
      
 163 
     | 
    
         
            +
                    # This test ensures that the changes don't break existing functionality
         
     | 
| 
      
 164 
     | 
    
         
            +
             
     | 
| 
      
 165 
     | 
    
         
            +
                    # Mock the method binding
         
     | 
| 
      
 166 
     | 
    
         
            +
                    method_argnames = ['text', 'temperature']
         
     | 
| 
      
 167 
     | 
    
         
            +
             
     | 
| 
      
 168 
     | 
    
         
            +
                    # Simulate existing call without with_proto
         
     | 
| 
      
 169 
     | 
    
         
            +
                    args = ('test input',)
         
     | 
| 
      
 170 
     | 
    
         
            +
                    kwargs = {'temperature': 0.7}
         
     | 
| 
      
 171 
     | 
    
         
            +
             
     | 
| 
      
 172 
     | 
    
         
            +
                    # Extract with_proto (should default to False)
         
     | 
| 
      
 173 
     | 
    
         
            +
                    with_proto = kwargs.pop('with_proto', False)
         
     | 
| 
      
 174 
     | 
    
         
            +
             
     | 
| 
      
 175 
     | 
    
         
            +
                    # Verify existing behavior is preserved
         
     | 
| 
      
 176 
     | 
    
         
            +
                    self.assertIs(with_proto, False)
         
     | 
| 
      
 177 
     | 
    
         
            +
                    self.assertEqual(len(args), 1)
         
     | 
| 
      
 178 
     | 
    
         
            +
                    self.assertEqual(kwargs, {'temperature': 0.7})
         
     | 
| 
      
 179 
     | 
    
         
            +
             
     | 
| 
      
 180 
     | 
    
         
            +
                    # Ensure parameter count validation still works
         
     | 
| 
      
 181 
     | 
    
         
            +
                    self.assertLessEqual(len(args), len(method_argnames))
         
     | 
| 
      
 182 
     | 
    
         
            +
                    self.assertLessEqual(len(args) + len(kwargs), len(method_argnames))
         
     | 
| 
      
 183 
     | 
    
         
            +
             
     | 
| 
      
 184 
     | 
    
         
            +
                def test_documentation_shows_with_proto_support(self):
         
     | 
| 
      
 185 
     | 
    
         
            +
                    """Test that the feature is properly documented in method docstrings"""
         
     | 
| 
      
 186 
     | 
    
         
            +
             
     | 
| 
      
 187 
     | 
    
         
            +
                def test_reserved_parameter_validation(self):
         
     | 
| 
      
 188 
     | 
    
         
            +
                    """Test that with_proto parameter name is properly validated in ModelClass methods"""
         
     | 
| 
      
 189 
     | 
    
         
            +
                    from clarifai.runners.utils.method_signatures import (
         
     | 
| 
      
 190 
     | 
    
         
            +
                        RESERVED_PARAM_WITH_PROTO,
         
     | 
| 
      
 191 
     | 
    
         
            +
                        build_function_signature,
         
     | 
| 
      
 192 
     | 
    
         
            +
                    )
         
     | 
| 
      
 193 
     | 
    
         
            +
             
     | 
| 
      
 194 
     | 
    
         
            +
                    # Test that a function with with_proto parameter raises an error
         
     | 
| 
      
 195 
     | 
    
         
            +
                    def invalid_method(self, text: str, with_proto: bool = False) -> str:
         
     | 
| 
      
 196 
     | 
    
         
            +
                        return text
         
     | 
| 
      
 197 
     | 
    
         
            +
             
     | 
| 
      
 198 
     | 
    
         
            +
                    with self.assertRaises(ValueError) as context:
         
     | 
| 
      
 199 
     | 
    
         
            +
                        build_function_signature(invalid_method)
         
     | 
| 
      
 200 
     | 
    
         
            +
             
     | 
| 
      
 201 
     | 
    
         
            +
                    error_msg = str(context.exception)
         
     | 
| 
      
 202 
     | 
    
         
            +
                    self.assertIn(RESERVED_PARAM_WITH_PROTO, error_msg)
         
     | 
| 
      
 203 
     | 
    
         
            +
                    self.assertIn("reserved", error_msg.lower())
         
     | 
| 
      
 204 
     | 
    
         
            +
             
     | 
| 
      
 205 
     | 
    
         
            +
                def test_reserved_parameter_constant_usage(self):
         
     | 
| 
      
 206 
     | 
    
         
            +
                    """Test that the constant is used consistently in ModelClient"""
         
     | 
| 
      
 207 
     | 
    
         
            +
                    from clarifai.runners.utils.method_signatures import RESERVED_PARAM_WITH_PROTO
         
     | 
| 
      
 208 
     | 
    
         
            +
             
     | 
| 
      
 209 
     | 
    
         
            +
                    # Test parameter extraction using the constant
         
     | 
| 
      
 210 
     | 
    
         
            +
                    test_kwargs = {'param1': 'value1', RESERVED_PARAM_WITH_PROTO: True, 'param2': 'value2'}
         
     | 
| 
      
 211 
     | 
    
         
            +
             
     | 
| 
      
 212 
     | 
    
         
            +
                    # Extract with_proto parameter using the constant
         
     | 
| 
      
 213 
     | 
    
         
            +
                    with_proto = test_kwargs.pop(RESERVED_PARAM_WITH_PROTO, False)
         
     | 
| 
      
 214 
     | 
    
         
            +
             
     | 
| 
      
 215 
     | 
    
         
            +
                    # Verify extraction worked correctly
         
     | 
| 
      
 216 
     | 
    
         
            +
                    self.assertIs(with_proto, True)
         
     | 
| 
      
 217 
     | 
    
         
            +
                    self.assertNotIn(RESERVED_PARAM_WITH_PROTO, test_kwargs)
         
     | 
| 
      
 218 
     | 
    
         
            +
                    self.assertEqual(test_kwargs, {'param1': 'value1', 'param2': 'value2'})
         
     | 
| 
      
 219 
     | 
    
         
            +
             
     | 
| 
      
 220 
     | 
    
         
            +
             
     | 
| 
      
 221 
     | 
    
         
            +
            if __name__ == '__main__':
         
     | 
| 
      
 222 
     | 
    
         
            +
                unittest.main()
         
     | 
| 
         @@ -1 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            __version__ = "11.8.4"
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
    
        {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/datasets/upload/loaders/imagenet_classification.py
    RENAMED
    
    | 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
    
        {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/dockerfile_template/Dockerfile.template
    RENAMED
    
    | 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
    
        {clarifai-11.8.4 → clarifai-11.8.5}/clarifai/runners/pipeline_steps/pipeline_step_builder.py
    RENAMED
    
    | 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     |