Kalliope needs the community to improve its Core features and to create new Neurons. Let's join us !
The community can contribute to the Core of Kalliope by providing some new features.
git checkout -b my-new-feature
git commit -am 'Add some feature'
git push origin my-new-feature
Kalliope modularity is fully based on Neuron so the community can contribute by adding their own. Neurons are independent projects so they can be developed under a github project. Anyone can clone them, place them under the neurons repository and reuse them.
Creating a new Neuron must follow some rules:
The Neuron inherits from the NeuronModule coming from the Core.
from core.NeuronModule import NeuronModule
class Say(NeuronModule):
The Neuron has a constructor init which is the entry point. The constructor has a **kwargs argument which is corresponding to the Dict of incoming variables:values defined either in the brain file or in the signal.
The Neuron must refer to its parent structure in the init by calling the super of NeuronModule.
def __init__(self, **kwargs):
super(Say, self).__init__(**kwargs)
You must run unit tests with success before sending a pull request. Add new tests that cover the code you want to publish.
cd /path/to/kalliope
python -m unittest discover
(optionnal-> good practice) The Neuron can implement a private method _is_parameters_ok(self) which checks if entries are ok. return: true if parameters are ok, raise an exception otherwise
(optionnal-> good practice) The Neuron can import and raise exceptions coming from NeuronModule:
The Neuron can use a self.say(message) method to speak out some return values using the say_template attribute in the brain file. the message variable must be a Dict of variable:values where variables can be defined as output.
Example of neuron structure
myneuron/
├── __init__.py
├── myneuron.py
├── README.md
└── tests
├── __init__.py
└── test_myneuron.py
Example of neuron code
class Myneuron(NeuronModule):
def __init__(self, **kwargs):
super(Myneuron, self).__init__(**kwargs)
# the args from the neuron configuration
self.arg1 = kwargs.get('arg1', None)
self.arg2 = kwargs.get('arg2', None)
# check if parameters have been provided
if self._is_parameters_ok():
# -------------------
# do amazing code
# -------------------
def _is_parameters_ok(self):
"""
Check if received parameters are ok to perform operations in the neuron
:return: true if parameters are ok, raise an exception otherwise
.. raises:: MissingParameterException
"""
if self.arg1 is None:
raise MissingParameterException("You must specify a arg1")
if not isinstance(self.arg2, int):
raise MissingParameterException("arg2 must be an integer")
return True
The Neuron must (as much as possible) ensure the i18n. This means that they should not manage a specific language inside its own logic. Only Synapse by the use of Order must interact with the languages. This allow a Neuron to by reused by anyone, speaking any language.
Respect PEP 257 -- Docstring conventions. For each class or method add a description with summary, input parameter, returned parameter, type of parameter
def my_method(my_parameter):
"""
Description of he method
:param my_parameter: description of he parameter
:type my_parameter: str
"""
Respect PEP 8 -- Style Guide for Python Code We recommend the usage of an IDE like Pycharm
They are managed like Neurons, you can follow the same process to develop your own !
Incoming
We are maintening a list of all the Neurons available from the community, let us know