@@ -123,6 +123,8 @@ def __init__(
123123
124124 self .deployment_user_id = deployment_user_id
125125
126+ self .load_info (validate = True )
127+
126128 self ._set_runner_selector (
127129 compute_cluster_id = compute_cluster_id ,
128130 nodepool_id = nodepool_id ,
@@ -1235,7 +1237,20 @@ def _list_concepts(self) -> List[str]:
12351237 )
12361238 return [concept_info ['concept_id' ] for concept_info in all_concepts_infos ]
12371239
1238- def load_info (self ) -> None :
1240+ def load_info (self , validate : bool = False ) -> None :
1241+ """Loads the model information from the Clarifai API.
1242+
1243+ This method makes a gRPC call to the GetModel endpoint to fetch the latest
1244+ information for the model instance and updates its attributes.
1245+
1246+ Args:
1247+ validate (bool, optional): If True, the method will only validate the existence
1248+ of the model on the backend without updating the local object's attributes.
1249+ Defaults to False.
1250+
1251+ Raises:
1252+ Exception: If the gRPC API call fails.
1253+ """
12391254 """Loads the model info."""
12401255 request = service_pb2 .GetModelRequest (
12411256 user_app_id = self .user_app_id ,
@@ -1247,10 +1262,11 @@ def load_info(self) -> None:
12471262 if response .status .code != status_code_pb2 .SUCCESS :
12481263 raise Exception (response .status )
12491264
1250- dict_response = MessageToDict (response , preserving_proto_field_name = True )
1251- self .kwargs = self .process_response_keys (dict_response ['model' ])
1252- self .model_info = resources_pb2 .Model ()
1253- dict_to_protobuf (self .model_info , self .kwargs )
1265+ if not validate :
1266+ dict_response = MessageToDict (response , preserving_proto_field_name = True )
1267+ self .kwargs = self .process_response_keys (dict_response ['model' ])
1268+ self .model_info = resources_pb2 .Model ()
1269+ dict_to_protobuf (self .model_info , self .kwargs )
12541270
12551271 def __str__ (self ):
12561272 if len (self .kwargs ) < 10 :
0 commit comments