@@ -381,12 +381,12 @@ def add_input(self, input):
381381 Raises
382382 ------
383383 ValueError
384- If input contains property other than 'name', 'data_type'
385- and 'dims' or any of the properties are not set, or if an
386- input with the same name already exists in the configuration
387- but has different data_type or dims property
384+ If input contains property other than 'name', 'data_type',
385+ 'dims', 'optional' or any of the non-optional properties
386+ are not set, or if an input with the same name already exists
387+ in the configuration but has different data_type or dims property
388388 """
389- valid_properties = ["name" , "data_type" , "dims" ]
389+ valid_properties = ["name" , "data_type" , "dims" , "optional" ]
390390 for current_property in input :
391391 if current_property not in valid_properties :
392392 raise ValueError (
@@ -447,9 +447,26 @@ def add_input(self, input):
447447 + " but the model configuration specifies dims "
448448 + str (current_input ["dims" ])
449449 )
450+ elif (
451+ "optional" in current_input
452+ and "optional" in input
453+ and current_input ["optional" ] != input ["optional" ]
454+ ):
455+ raise ValueError (
456+ "model '"
457+ + self ._model_config ["name" ]
458+ + "', tensor '"
459+ + input ["name" ]
460+ + "': the model expects optional "
461+ + str (input ["optional" ])
462+ + " but the model configuration specifies optional "
463+ + str (current_input ["optional" ])
464+ )
450465 else :
451466 current_input ["data_type" ] = input ["data_type" ]
452467 current_input ["dims" ] = input ["dims" ]
468+ if "optional" in input :
469+ current_input ["optional" ] = input ["optional" ]
453470 return
454471
455472 self ._model_config ["input" ].append (input )
@@ -538,6 +555,53 @@ def add_output(self, output):
538555
539556 self ._model_config ["output" ].append (output )
540557
558+ def set_model_transaction_policy (self , transaction_policy_dict ):
559+ """
560+ Set model transaction policy for the model.
561+ Parameters
562+ ----------
563+ transaction_policy_dict : dict
564+ The dict, containing all properties to be set as a part
565+ of `model_transaction_policy` field.
566+ Raises
567+ ------
568+ ValueError
569+ If transaction_policy_dict contains property other
570+ than 'decoupled', or if `model_transaction_policy` already exists
571+ in the configuration, but has different `decoupled` property.
572+ """
573+ valid_properties = ["decoupled" ]
574+ for current_property in transaction_policy_dict .keys ():
575+ if current_property not in valid_properties :
576+ raise ValueError (
577+ "model transaction property in auto-complete-config "
578+ + "function for model '"
579+ + self ._model_config ["name" ]
580+ + "' contains property other than 'decoupled'."
581+ )
582+
583+ if "model_transaction_policy" not in self ._model_config :
584+ self ._model_config ["model_transaction_policy" ] = {}
585+
586+ if "decoupled" in transaction_policy_dict .keys ():
587+ if (
588+ "decoupled" in self ._model_config ["model_transaction_policy" ]
589+ and self ._model_config ["model_transaction_policy" ]["decoupled" ]
590+ != transaction_policy_dict ["decoupled" ]
591+ ):
592+ raise ValueError (
593+ "trying to change decoupled property in auto-complete-config "
594+ + "for model '"
595+ + self ._model_config ["name" ]
596+ + "', which is already set to '"
597+ + str (self ._model_config ["model_transaction_policy" ]["decoupled" ])
598+ + "'."
599+ )
600+
601+ self ._model_config ["model_transaction_policy" ][
602+ "decoupled"
603+ ] = transaction_policy_dict ["decoupled" ]
604+
541605
542606TRITONSERVER_REQUEST_FLAG_SEQUENCE_START = 1
543607TRITONSERVER_REQUEST_FLAG_SEQUENCE_END = 2
0 commit comments