OpenFabrics / sunfish_library_reference

The core Sunfish implementation
BSD 3-Clause "New" or "Revised" License
2 stars 4 forks source link

Agent mode for the Sunfish reference library #27

Open christian-pinto opened 1 month ago

christian-pinto commented 1 month ago

In the sunfish reference library enable/implement a subset of the API specific to Agents. This is to be used for implementing the core services that are required by agents without having to re-use (abuse) the entire sunfish core.

christian-pinto commented 1 month ago

While discussing with @rherrell about enablenf an agent mode we realized that the main functionalities that would need to be forked for sunfish vs agent are:

  1. Forwarding or a request to its source
  2. In case RedFish events are also used as a form of communication between agent and hardware manager(s), the agent might want to provide an implementation of the event handler interface (https://github.com/OpenFabrics/sunfish_library_reference/blob/main/sunfish/events/event_handler_interface.py) that is specific to its own architecture

In both cases, an agent implementation would need to augment the sunfish library by providing a new implementation of the required functionalities that the sunfish library can load dynamically. One thing I would like to avoid is having to hack the code of the library for every new agent coming with a new event handler or source forwarding interface.

I have explored ways of creating a plugin mechanisms in which the event handler and forwarding logic become plugins that can be installed at runtime by the agent. The way I expect this to work is the following:

  1. Users install the sunfish library (pip install ....) in their agent environment
  2. Users create an agent project including plugins for the functionalities to boe added at runtime to the sunfish library
  3. Users start their agent project that dynamically triggers the sunfish library to load the new plugins.
    • The agent mode is enabled in the sunfish library config file
    • Class names for the plugins to be used can be passed in the sunfish library config file

With the above process users would always use the latest version of the sunfish library without having to customize it for working as an agent.

A way of creating plugins in python that can be loaded from the agent into the sunfish library would be using namespace packages.

The agent reference will provide an example on how to load such plugins.

I will work on an example before introducing this change in the main library.

christian-pinto commented 6 days ago

To support using the same library in server and agent mode I have implemented dynamically loadable plugins that can change the behaviour of the sunfish library without having to modify the core library.

In the specific, we now support event handlers, storage backends and redfish object handlers as loadable plugins. A description of how this is implemented included in the comments inside the codebase and in the description of PR #29 . I will also update the documentation accordingly.

With this functionality there is no need for a special agent mode but rather, aagents can provide their implementation handlers and storage backend as needed.

@rherrell