@@ -1131,10 +1131,19 @@ class CustomEvalFunction(EvalFunctionConfig):
11311131 @classmethod
11321132 def expected_name (cls ) -> str :
11331133 raise NotImplementedError (
1134- "Custm evaluation functions are coming soon"
1134+ "Custom evaluation functions are coming soon"
11351135 ) # Placeholder: See super().eval_func_entry for actual name
11361136
11371137
1138+ class ExternalEvalFunction (EvalFunctionConfig ):
1139+ def __call__ (self , ** kwargs ):
1140+ raise NotImplementedError ("Cannot call an external function" )
1141+
1142+ @classmethod
1143+ def expected_name (cls ) -> str :
1144+ return "external_function"
1145+
1146+
11381147class StandardEvalFunction (EvalFunctionConfig ):
11391148 """Class for standard Model CI eval functions that have not been added as attributes on
11401149 AvailableEvalFunctions yet.
@@ -1186,6 +1195,7 @@ def expected_name(cls) -> str:
11861195 CuboidPrecisionConfig ,
11871196 CategorizationF1Config ,
11881197 CustomEvalFunction ,
1198+ ExternalEvalFunction ,
11891199 EvalFunctionNotAvailable ,
11901200 StandardEvalFunction ,
11911201 PolygonMAPConfig ,
@@ -1229,7 +1239,12 @@ def __init__(self, available_functions: List[EvalFunctionEntry]):
12291239 self ._custom_to_function : Dict [str , CustomEvalFunction ] = {
12301240 f .name : CustomEvalFunction (f )
12311241 for f in available_functions
1232- if not f .is_public
1242+ if not f .is_public and not f .is_external_function
1243+ }
1244+ self ._external_to_function : Dict [str , ExternalEvalFunction ] = {
1245+ f .name : ExternalEvalFunction (f )
1246+ for f in available_functions
1247+ if f .is_external_function
12331248 }
12341249 self .bbox_iou : BoundingBoxIOUConfig = (
12351250 self ._assign_eval_function_if_defined (BoundingBoxIOUConfig )
@@ -1294,8 +1309,9 @@ def __repr__(self):
12941309 str (name ).lower () for name in self ._public_func_entries .keys ()
12951310 ]
12961311 return (
1297- f"<AvailableEvaluationFunctions: public:{ functions_lower } "
1298- f"private: { list (self ._custom_to_function .keys ())} "
1312+ f"<AvailableEvaluationFunctions: public: { functions_lower } "
1313+ f"private: { list (self ._custom_to_function .keys ())} "
1314+ f"external: { list (self ._external_to_function .keys ())} "
12991315 )
13001316
13011317 @property
@@ -1312,13 +1328,22 @@ def public_functions(self) -> Dict[str, EvalFunctionConfig]:
13121328
13131329 @property
13141330 def private_functions (self ) -> Dict [str , CustomEvalFunction ]:
1315- """Custom functions uploaded to Model CI
1331+ """Private functions uploaded to Model CI
13161332
13171333 Returns:
13181334 Dict of function name to :class:`CustomEvalFunction`.
13191335 """
13201336 return self ._custom_to_function
13211337
1338+ @property
1339+ def external_functions (self ) -> Dict [str , ExternalEvalFunction ]:
1340+ """External functions uploaded to Model CI
1341+
1342+ Returns:
1343+ Dict of function name to :class:`ExternalEvalFunction`.
1344+ """
1345+ return self ._external_to_function
1346+
13221347 def _assign_eval_function_if_defined (
13231348 self ,
13241349 eval_function_constructor : Callable [[EvalFunctionEntry ], EvalFunction ],
@@ -1340,6 +1365,7 @@ def from_id(self, eval_function_id: str):
13401365 for eval_func in itertools .chain (
13411366 self ._public_to_function .values (),
13421367 self ._custom_to_function .values (),
1368+ self ._external_to_function .values (),
13431369 ):
13441370 if eval_func .id == eval_function_id :
13451371 return eval_func
0 commit comments