Commit 704390b2 authored by Ivan Vanat's avatar Ivan Vanat
Browse files

beta version of new module implementation tutorial

parent b3786c08
Loading
Loading
Loading
Loading
+33 −3
Original line number Diff line number Diff line
@@ -164,10 +164,40 @@ Options:
  --help                          Show this message and exit.
```

## Adding new module

* Give your module a name. Add it to _config\_template.yml_ under _tool\_order_ key. Assigned value is used for default run order of the module (lower - higher priority)

* Create new class in core/tools folder which implements core/tools/tool\_interface and implement it. In case the module would be decomposed into multiple files we recommend creating a new folder within core/tools folder. In such case make sure to have empty file called _\_\_init\_\_.py_ in order to make the files importable.

* Any classes used to only hold data created within your module should be created within entities/ folder and should inherit from entities/base\_element. DO NOT use base\_element as output of your module. It can be safely used for storing features of your module's elements within _element.features_ attribute.

* If needed create your own output object in output/output\_objects which should inherit from output/output\_objects/base\_output\_object. If base\_output\_object is sufficient you can use that in the next step. This object will be used in output generator.

* In your implementation of the tool in core/tools make sure to assign value to _output\_object_ attribute at the end of the _run()_ method to either an instance of your newly created output object class or the base which is already provided.

* For output generation there are two options:
	1. Implement _\_\_str\_\_()_ in your output object class. Default output generator will then be assigned to your module which will call this.
	2. Implement output generator class which should inherit from output\output\_generators\base\_output\_generator class. This class will be passed whatever is in your _module.output\_object_ attribute.

* Lastly, in _core/module\_management/modules.py_ create new method which should follow already existing conventions _\_create\_\<your module's name\>\_module_ and have no return value. Within the method you should create an instance of core/module\_management/module class which consists of four attributes:
	1. name - name of your module as specified in _config\_template.yml_
	2. tool - instance of your module class
	3. element\_type - type of the elements returned by your module (should be in entities/ folder)
	4. output_generator - instance of your output generator class. If it is none default output generator will be provided by our code.
All command line arguments + sequence are stored within _arguments_ attribute.

* Call your new method in _\_prepare\_modules_ method.

* Reinstall entire tool by calling installation script.
```
    sudo ./teGreedyNester_installation_v1.sh
```

## Adding new LTR discovery tool

* Create new class which implements core/tools/discovery\_tool\_interface and implement required run() method
* Create new class which implements core/tools/ltr/discovery\_tool\_interface and implement required _run()_ method

* Add new value to core/DiscoveryTool.py including any aliases, make sure the numeric value is different from already implemented tools and that it is the same for all of your aliases. (used in calling nester ``-dt <value you set>``)
* Add new value to core/tools/ltr/DiscoveryTool.py including any aliases, make sure the numeric value is different from already existing values and that it is the same for all of your aliases. (used in calling nester ``-dt <enum value/alias you set>``)

* Import your newly implemented class in utils/DependencyResolver.py and add it to ``valueToClassDict`` attribute. (key is numeric value you set in core/DiscoveryTool.py)
* Import your newly implemented class in utils/DependencyResolver.py and add it to ``value_to_class`` attribute. (key is numeric value you set in core/tools/ltr/DiscoveryTool.py and value is an instance of your class)