orangeqs.juice._entrypoints#
Management of entry points defined by extensions for the Juice client.
Module Contents#
Functions#
Collect all entry points in the specified group. |
|
Possibly wrap a function to make it a method of an object. |
API#
- orangeqs.juice._entrypoints.collect_entry_points(group: str) dict[str, importlib.metadata.EntryPoint]#
Collect all entry points in the specified group.
Currently, we support entrypoints for Juice Client and Dashboard.
Parameters#
group (str): The entry point group name.
Returns#
(dict): A mapping of method names to entrypoint objects. These are the methods that should be injected into the Juice client.
Raises#
(RuntimeError): If multiple entry points define the same method name.
- orangeqs.juice._entrypoints.wrap_function_as_method(object_type: type[orangeqs.juice._entrypoints._T], object_instance: orangeqs.juice._entrypoints._T, method: collections.abc.Callable[orangeqs.juice._entrypoints._P, orangeqs.juice._entrypoints._R] | collections.abc.Callable[Concatenate[orangeqs.juice._entrypoints._T, orangeqs.juice._entrypoints._P], orangeqs.juice._entrypoints._R]) collections.abc.Callable[orangeqs.juice._entrypoints._P, orangeqs.juice._entrypoints._R]#
Possibly wrap a function to make it a method of an object.
If the function is determined to be a method, it is wrapped to take the client instance as the first parameter. Uses a simple heuristic to determine if the function is a client method:
If the first parameter has type annotations, check if it is the object type.
Otherwise, check if the first parameter is named ‘client’.
The function that is returned can be set on
object_instanceusingsetattr()and will behave as a method of that instance.Parameters#
object_type (type): The type of the object instance to check type annotations against.
object_instance (instance of
object\_type): The instance of the object to which the method will be bound.method (callable): The function to possibly wrap.
Returns#
(callable): The wrapped method that can be set using
setattr()onobject_instance.