garmentiq.landmark.derivation.process
Dispatching a derivation request to its registered function.
1"""Dispatching a derivation request to its registered function.""" 2from .derive_keypoint_coord import derive_keypoint_coord 3 4 5def process(**args): 6 """ 7 Dispatches to the appropriate derivation function based on the 'function' name 8 provided in the arguments. 9 10 This function acts as a router, taking a dictionary of arguments which 11 includes the name of the derivation function to call (under a key 12 that matches a function name in its internal dispatch table). 13 14 Args: 15 **args: Keyword arguments where one key's value is a dictionary 16 containing the arguments for a specific derivation function, 17 and that key's name corresponds to the derivation function. 18 Example: `{'derive_keypoint_coord': {'p1_id': 1, ...}}` 19 20 Raises: 21 ValueError: If the function name specified in `args` is unknown. 22 23 Returns: 24 Any: The result returned by the dispatched derivation function. 25 """ 26 dispatch = { 27 "derive_keypoint_coord": derive_keypoint_coord, 28 } 29 for func_name, func_args in args.items(): 30 if func_name not in dispatch: 31 raise ValueError(f"Unknown function: {func_name}") 32 return dispatch[func_name](**func_args)
def
process(**args):
6def process(**args): 7 """ 8 Dispatches to the appropriate derivation function based on the 'function' name 9 provided in the arguments. 10 11 This function acts as a router, taking a dictionary of arguments which 12 includes the name of the derivation function to call (under a key 13 that matches a function name in its internal dispatch table). 14 15 Args: 16 **args: Keyword arguments where one key's value is a dictionary 17 containing the arguments for a specific derivation function, 18 and that key's name corresponds to the derivation function. 19 Example: `{'derive_keypoint_coord': {'p1_id': 1, ...}}` 20 21 Raises: 22 ValueError: If the function name specified in `args` is unknown. 23 24 Returns: 25 Any: The result returned by the dispatched derivation function. 26 """ 27 dispatch = { 28 "derive_keypoint_coord": derive_keypoint_coord, 29 } 30 for func_name, func_args in args.items(): 31 if func_name not in dispatch: 32 raise ValueError(f"Unknown function: {func_name}") 33 return dispatch[func_name](**func_args)
Dispatches to the appropriate derivation function based on the 'function' name provided in the arguments.
This function acts as a router, taking a dictionary of arguments which includes the name of the derivation function to call (under a key that matches a function name in its internal dispatch table).
Arguments:
- **args: Keyword arguments where one key's value is a dictionary
containing the arguments for a specific derivation function,
and that key's name corresponds to the derivation function.
Example:
{'derive_keypoint_coord': {'p1_id': 1, ...}}
Raises:
- ValueError: If the function name specified in
argsis unknown.
Returns:
Any: The result returned by the dispatched derivation function.