This is simple README for nlp_service
Author: Radosław Warzocha
Mail:	radoslaw.warzocha@gmail.com

nlp_service package is constructed so future work on nlp services can be conducted easily
and changes don't have to be made in every service ever created.

1. INSTALLATION
setup.py script for easy installation is provided. To install nlp_service package and any
services you may find necessarry just type

> sudo python setup.py install

Then the script will ask you to choose which of the services you want to install.

2. CREATING NEW SERVICE

Whenever we are creating new service we have to do 2 things:
- create new service subclass with `process` function overriden and provide executable script
- prepare services __init__.py and add service paths to setup.py

2.1. Creating service code
To create new service all you need to do is import Service class from nlp_service package and
subclass it. There is no need (and in fact you shouldn't do it) to override any of the functions
from Service class apart from `processing` function. If you really need to do this remember to
always begin with invoking baseclass function.

simplest subclass look like this:

from nlp_service import Serice
class MyService(Service):
	def __init__(self, *args, **kwargs):
		super(MyService, self).__init__(*args, **kwargs)

	def process(self, task_file, task_options):
		do_something(task_file, task_options)

Notice that you have to write the dummy constructor invoking baseclass __init__ as python doesn't
implicitly invoke it by itself.
task_file is a path to the file to process
task_options is a dictionary of necessary options

Next you need to provide exectuable script that will run the service.
Easiest way is to do something like this:

if __name__ == "__main__":
	parser = create_service_option_parser()
	args = parser.parse_args()
	config_path = args.config
	logfile_path = args.log_file
	logging_lvl = args.logging
	run_as_daemon = args.daemon

	my_service = MyService(config_path, logfile_path, logging_lvl, run_as_daemon)
	my_service.run()

For your convinience nlp_service has `create_sevice_option_parser` function, which creates ArgumentParser
instance. If you want to provide your own options you can extend this parser easily (consult python's
docs on ArgumentParser for further details).
As for the service constructor arguments:
config_path 	- path to service config file (example config file is in nlp_service/config.ini)
logfile_path 	- path to logfile (optional)
logging_lvl	- possible values: DEBUG, INFO, WARNING, ERROR (optional, default: INFO)
run_as_daemon	- if the service should be ran in background (optional, default: False)

That is all you need to know to create new working service :)

2.2. Adding installation info
For our service to be easily installable via setup.py script we need to:
- provide __init__.py file - that way we are not limited to one-file services
- add our new service to the `services_to_install` dictionary in setup.py:
services_to_install = {..., my_service_dir_name: my_service_executable_file_basename}

That way the installer will ask user about if it should install this new service, will install it as package
as well as eexecutable, which can then be run with single command:

sudo my_service.py

