Open hoh opened 2 years ago
Example plz
Description updated
So given the implementation of AlephApp
in vm/app.py, I can create a function like this:
def get_filters(self):
filters = []
for event_handler in self.event_handlers:
filters.extend(event_handler.filters)
return filters
to get all of the defined filters of the app in the format required to react on message events.
The task would now be to parse the code to be uploaded in the VM (if it is Python code), find the AlephApp object and call .get_filters()
, correct? Two issues I see that might come up:
aleph program
command do it already in their VM's environment, so we can eval the code nonetheless.
Context
We are working on improving the launch of VMs in reaction to the publication of Aleph messages.
The current implementation of the feature relies on:
1. The message defines filters to react to
A message of type PROGRAM can define to react to Aleph messages in the following form:
2. The program uses decorators to specify which functions to call
Problem
This requires developers to write their filters twice: in the Python decorators and in the PROGRAM message definition. This may lead to an inconsistency between the two definitions.
It would be useful for app developers to have a tool that generates the values of
content.on.message
based on the filters used in the Python code.