Package: live-agent
Live AgentCoordinates the execution of processes which interact with Intelie Live and simplifies their deployment.Processes are implemented inside modules, segmented by its goal. The existing processes can be found atlive_agent/modulesEach module can have:datasources: Process which generates and send events to livemonitors: Processes which respond to events generated by querieslogic_adapters: Classes which handle messages received by the chatbotAlive_agentmodule should expose aPROCESSESdictionary, listing all processes it provides.
A process is started by a function (usually namedstart) which accepts two parameters:settings: a dictionary of the settings for this process;kwargs: a dictionary of extra parameters provided bylive-agent's runtime to this process.The set of active modules (among other things) is defined using a settings file.
The modulechatbotincludes an example settings file.live-agentrequires python 3.7 or newer.Usage# 1- Create a virtualenv using your preferred tool# 2- Activate the virtualenv# 3- Install live-agent (you should use a requirements.txt file to manage your dependencies)(virtualenv)$pipinstalllive-agent[chatbot]# 4- Bootstrap a new agent(virtualenv)$create-agent
Creatingtheagentfiles:
-Creating"README.md"-Creating"settings.json"-Creatingfolder"tools"-Creatingfolder"modules"-Creating"modules/__init__.py"Addingprojectsettings:
-Creating"dev-requirements.txt"-Creating"pyproject.toml"-Creating".pre-commit-config.yaml"done# 5- Create the initial structure for each of your agent's modules(virtualenv)$add-agent-moduleexample--empty
Creatingthemodule"example"-Creatingfolder"modules"-Creatingfolder"modules/example"-Creatingfolder"modules/example/logic_adapters"-Creatingfolder"modules/example/monitors"-Creatingfolder"modules/example/datasources"done# 5.1- Or, use a sample module as reference(virtualenv)$add-agent-moduleexample
Creatingthemodule"example"-Creatingfolder"modules"-Removingoldfolder"modules/example"-Creatingfolder"modules/example"withexamplecode

Themodule"example"containsa"requirements.txt"file
Makesurethatthesedependenciesareaddedtothemainrequirements

Inordertoruntheagentwiththismodule,execute:
agent-controlconsole--settings=modules/example/settings_template.jsondone# 6- Implement the features you need on your modules and add them to settings.json# Use the command `validate-settings` to validate the settings$validate-settings--settings=settings.json# 7- Execute the agent$agent-controlconsole--settings=settings.jsonDevelopmentThis project usesblackandpre-commitProject setup:# 1- Create a virtualenv# 2- Activate the virtualenv# 3- Install project requirements$pipinstall-rrequirements.txt-rlive_agent/modules/chatbot/requirements.txt# 4- Check is your settings file seems to be correct$validate-settings--settings=modules/chatbot/settings_template.json# 5- Execute the agent$./live_agent/scripts/agent-controlconsole--settings=modules/chatbot/settings_template.jsonReading logsThis project useseliotfor logging. Eliot generates log messages as json objects,
which can be parsed by tools likeeliot-treeandeliot-prettyprintor sent to Intelie Live.The log file is stored at/var/log/live-agent.logby default. Make sure the user which will start the agent can write to this file.
The log messages are also sent to live, using the event_typedda_logby default.# Reading the log with eliot-prettyprint$tail-f/var/log/live-agent.log|eliot-prettyprint# Reading the log with eliot-tree (extra dependency, already on requirements.txt)$eliot-tree-l0/var/log/live-agent.logBuilding releasesIn order to generate an installable package you will need to usedocker.Install docker (check the documentation for your system:https://docs.docker.com/install/)Add your user to the groupdocker:$ usermod -aG docker <username>.Log off and log on again for the group to be recognized. (or you can simply$ su - <username>on your terminal)The packager requires packagesfabricandvirtualenv. It will generate a rpm file for installation on the target system.$tools/package.shc7c7: Build for centos7 and derivates (redhat 7, amazon linux 2, etc)Testing the built packages(As of now the testing is entirely manual)In a container:$tools/test-envs/run_centos_container.sh7# Build dir will be available at /packages, so you can install and testIn a VM:This allows to a more complete test, including running the app as a serviceInstall VirtualBox and Vagrant (https://www.vagrantup.com/downloads.html)# cd to `tools/test-envs/RedHat7`$cdtools/test-envs/RedHat7# Starting VM:$vagrantup# Connecting to the machine:$`vagrantssh`# To transfer files, copy to/from the `transf` subdirectory,# it is automatically mapped as `/transf` at the test VM# Stopping:$vagranthalt# Stop$vagrantdestroy# Completely erase the machineInstalling on the target system$rpm-Uvh<rpmfile>Publishing to pypi# Build the packages
$ python setup.py egg_info sdist

# Validate the package
$ twine check dist/*

# Upload the package
$ twine upload dist/*