|
@@ -58,10 +58,10 @@ The constructor has a __**kwargs argument__ which is corresponding to the Dict o
|
|
|
```
|
|
|
|
|
|
1. 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
|
|
|
-```
|
|
|
+ ```
|
|
|
+ cd /path/to/kalliope
|
|
|
+ python -m unittest discover
|
|
|
+ ```
|
|
|
|
|
|
1. (*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*
|
|
|
1. (*optionnal-> good practice*) The Neuron can __import and raise exceptions__ coming from NeuronModule:
|
|
@@ -71,6 +71,46 @@ python -m unittest discover
|
|
|
1. 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.
|
|
|
|
|
|
+1. Example of neuron structure
|
|
|
+ ```
|
|
|
+ myneuron/
|
|
|
+ ├── __init__.py
|
|
|
+ ├── myneuron.py
|
|
|
+ ├── README.md
|
|
|
+ └── tests
|
|
|
+ ├── __init__.py
|
|
|
+ └── test_myneuron.py
|
|
|
+ ```
|
|
|
+
|
|
|
+1. Example of neuron code
|
|
|
+ ```
|
|
|
+ class Myneuron(NeuronModule):
|
|
|
+ def __init__(self, **kwargs):
|
|
|
+ super(Myneuron, self).__init__(**kwargs)
|
|
|
+ # ge 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
|
|
|
+ ```
|
|
|
+
|
|
|
##### Constraints
|
|
|
|
|
|
1. The Neuron must (as much as possible) ensure the i18n. This means that they should __not manage a specific languages__ inside its own logic.
|