@@ -28,7 +28,6 @@ class ModelConfig:
2828 """
2929 A class that encapsulates all the metadata about a Triton model.
3030 """
31-
3231 def __init__ (self , model_config ):
3332 """
3433 Parameters
@@ -39,6 +38,11 @@ def __init__(self, model_config):
3938 self ._model_config = model_config
4039 self ._cpu_only = False
4140
41+ def serialize (self ):
42+ model_config_dict = json_format .MessageToDict (self ._model_config )
43+ model_config_dict ['cpu_only' ] = self ._cpu_only
44+ return model_config_dict
45+
4246 def __getstate__ (self ):
4347 """
4448 Allows serialization of
@@ -49,6 +53,13 @@ def __getstate__(self):
4953 model_config_dict ['cpu_only' ] = self ._cpu_only
5054 return model_config_dict
5155
56+ def deserialize (self , model_config_dict ):
57+ self ._cpu_only = model_config_dict ['cpu_only' ]
58+ del model_config_dict ['cpu_only' ]
59+ protobuf_message = json_format .ParseDict (
60+ model_config_dict , model_config_pb2 .ModelConfig ())
61+ self ._model_config = protobuf_message
62+
5263 def __setstate__ (self , model_config_dict ):
5364 """
5465 Allows deserialization of
@@ -57,8 +68,8 @@ def __setstate__(self, model_config_dict):
5768
5869 self ._cpu_only = model_config_dict ['cpu_only' ]
5970 del model_config_dict ['cpu_only' ]
60- protobuf_message = json_format .ParseDict (model_config_dict ,
61- model_config_pb2 .ModelConfig ())
71+ protobuf_message = json_format .ParseDict (
72+ model_config_dict , model_config_pb2 .ModelConfig ())
6273 self ._model_config = protobuf_message
6374
6475 @staticmethod
@@ -114,8 +125,8 @@ def create_from_dictionary(model_dict):
114125 ModelConfig
115126 """
116127
117- protobuf_message = json_format .ParseDict (model_dict ,
118- model_config_pb2 .ModelConfig ())
128+ protobuf_message = json_format .ParseDict (
129+ model_dict , model_config_pb2 .ModelConfig ())
119130
120131 return ModelConfig (protobuf_message )
121132
@@ -159,7 +170,8 @@ def cpu_only(self):
159170
160171 return self ._cpu_only
161172
162- def write_config_to_file (self , model_path , src_model_path , last_model_path ):
173+ def write_config_to_file (self , model_path , src_model_path ,
174+ last_model_path ):
163175 """
164176 Writes a protobuf config file.
165177
0 commit comments