scistag.remotestag.service.RemoteService¶
- class RemoteService(identifier, multithreading=True)[source]¶
Bases:
objectDefines a service hosted on this machine. A service consists of one or multiple services sharing the same data.
- Parameters
identifier (
str) –The service’s unique identifier in the form com.company.ai.inference.yolov2.
A service’s name is not allowed to be contained within another service’s name.
multithreading (
bool) – Defines if this data can be accessed from multiple threads or is using thread local data (such as many ML libraries).
Methods
Overwrite this method with your deinitialization code.
Returns the service's identifier
Returns True if this service does NOT support multithreading and needs it's own worker thread
Overwrite this method with your initialization code.
Returns if the function is known
Registers a new function.
Registers a new function.
Executes a task
Unwraps a potentially single value result
Attributes
Key for single input value in the parameter dictionary
Key for the result value in the dictionary
__dict____doc____module____weakref__list of weak references to the object (if defined)
The service's identifier
Defines if the service is multithreading capable
Set of all registered functions
Data access lock
Defines the service was already stared
- deinitialize()[source]¶
Overwrite this method with your deinitialization code.
If this service is thread bound it’s guaranteed to be executed on the execution thread.
- get_identifier()[source]¶
Returns the service’s identifier
- Return type
- Returns
The identifier string
- get_single_threaded()[source]¶
Returns True if this service does NOT support multithreading and needs it’s own worker thread
- Return type
- Returns
True if not multithreading capable
- initialize()[source]¶
Overwrite this method with your initialization code.
- If this service is thread bound it’s guaranteed to be executed on the
later execution thread.
- register_callback(name, callback)[source]¶
Registers a new function. Functions can only be registered before the service was started.
- register_function(function)[source]¶
Registers a new function. Functions can only be registered before the service was started.
- Parameters
function (
RemoteFunction) – The function to register- Return True on success
- Return type
- run_task(function_name, parameters, unwrap=False)[source]¶
Executes a task
- Parameters
- Return type
- Returns
The function’s results
- INPUT_VALUE = '_value'¶
Key for single input value in the parameter dictionary
- RESULT_VALUE = '_resultValue'¶
Key for the result value in the dictionary
- _functions: dict[str, Union[scistag.remotestag.service_function.RemoteFunction, Callable[[dict], dict]]]¶
Set of all registered functions
- _identifier¶
The service’s identifier
- _lock¶
Data access lock
- _multithreading¶
Defines if the service is multithreading capable
- _started¶
Defines the service was already stared