Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
wiki:software:beuthbot:berichte:ss2020:zwischen [04.06.2020 12:23] Lukas Danckwerth |
wiki:software:beuthbot:berichte:ss2020:zwischen [04.06.2020 15:58] (aktuell) Lukas Danckwerth |
||
---|---|---|---|
Zeile 8: | Zeile 8: | ||
* Denny Schumann | * Denny Schumann | ||
- | ====Übersicht (Fragen, die beantwortet werden sollten)==== | + | ====Inhaltsangabe==== |
+ | |||
+ | - Einleitung / Aktueller Stand | ||
+ | - BeuthBot-Projekt | ||
+ | - deconcentrator-js | ||
+ | - Virtuellen Machine | ||
+ | - Funktionale Anforderungen | ||
+ | - Persistenz & Cache | ||
+ | - Microservices | ||
+ | - Ausblick | ||
===Was haben wir vorgefunden? | ===Was haben wir vorgefunden? | ||
Es wurden verschieden Github Projekte wie, Telegram Bot, Gateway, Deconcentrator, | Es wurden verschieden Github Projekte wie, Telegram Bot, Gateway, Deconcentrator, | ||
+ | ==Initial Project State== | ||
<uml> | <uml> | ||
@startuml | @startuml | ||
Zeile 63: | Zeile 73: | ||
Nun wurde der Beuth Bot gestartet, konnte allerdings nicht in Betrieb genommen werden, da dieser keine Netzwerkverbindung nach draußen hatte. Daraufhin wurde uns ein Server auf der Beuth zur verfügung gestellt, auf welchem der Beuth Bot letztendlich laufen sollte. Nachdem dieser dort versucht wurde eingerichtet zu werden, fehlte es dem Server an zugewiesenem Speicher, was erst behoben werden musste um den Bot vollständig installieren und in Betrieb nehmen zu können. Es konnten nach der Behebung des fehlenden Speichers letztendlich fast alle Docker-Container erfolgreich gestartet werden, bis auf den Service Deconcentrator, | Nun wurde der Beuth Bot gestartet, konnte allerdings nicht in Betrieb genommen werden, da dieser keine Netzwerkverbindung nach draußen hatte. Daraufhin wurde uns ein Server auf der Beuth zur verfügung gestellt, auf welchem der Beuth Bot letztendlich laufen sollte. Nachdem dieser dort versucht wurde eingerichtet zu werden, fehlte es dem Server an zugewiesenem Speicher, was erst behoben werden musste um den Bot vollständig installieren und in Betrieb nehmen zu können. Es konnten nach der Behebung des fehlenden Speichers letztendlich fast alle Docker-Container erfolgreich gestartet werden, bis auf den Service Deconcentrator, | ||
+ | |||
+ | ===Resultierende Aufgaben=== | ||
+ | |||
+ | * Dokumentation komplettieren / umstruktorieren | ||
+ | * Den alten deconcentrator " | ||
+ | * Übergeordnetes Git Projekt erstellen mit Paketen als Submodule | ||
===Wo stehen wir gerade?=== | ===Wo stehen wir gerade?=== | ||
Aktuell Ist der Beuth Bot vollständig in Betrieb genommen, dank des neu geschriebenen Deconcentrators. Ebenso liegt dieser nun, auf einem für uns zugreifbaren Server, welcher dort erfolgreich in Betrieb genommen wurde. Auch wurde er nun ermöglicht den gesamten Bot, welcher 8 Services beinhaltet mit zwei docker-compose files zu starten. Das Projekt wurde nun in 2 Git Submodule unterteilt, welche in Zukunft leichter bearbeitet werden können. Ebenfalls wurden sowohl in diesem Semester zu bearbeitende, | Aktuell Ist der Beuth Bot vollständig in Betrieb genommen, dank des neu geschriebenen Deconcentrators. Ebenso liegt dieser nun, auf einem für uns zugreifbaren Server, welcher dort erfolgreich in Betrieb genommen wurde. Auch wurde er nun ermöglicht den gesamten Bot, welcher 8 Services beinhaltet mit zwei docker-compose files zu starten. Das Projekt wurde nun in 2 Git Submodule unterteilt, welche in Zukunft leichter bearbeitet werden können. Ebenfalls wurden sowohl in diesem Semester zu bearbeitende, | ||
- | * was werden wir tun? | + | ===Wo werden wir tun?=== |
+ | Zusammengefasst, | ||
- | ====Challenges / Barriers==== | + | Auf diese Punkte wird im weiteren Verlauf dieses Dokuments eingegangen. |
- | + | ||
- | * Complex Project Structure | + | |
- | * Bad documentation of final state. So we ... | + | |
- | * Focused to long on the image of virtual machine | + | |
- | * Bad documentation of JSON format of messages | + | |
- | * Running out of space on Virtual Machine | + | |
- | * Current Situation with the Corona Virus | + | |
- | + | ||
- | ====Needs For Action==== | + | |
- | + | ||
- | * Complete Documentation | + | |
- | * "Kick out" the `deconcentrator` and `scraper` | + | |
- | * Create a master project containing the packages as submodules | + | |
- | ====Done so far==== | + | |
- | + | ||
- | ===Model of Messages of Telegram Bot=== | + | |
- | + | ||
- | < | + | |
- | @startuml | + | |
- | class Message { | + | |
- | message_id: Integer | + | |
- | from: User | + | |
- | chat: Chat | + | |
- | date: Long | + | |
- | text: String | + | |
- | } | + | |
- | + | ||
- | class User { | + | |
- | id: Integer | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | } | + | |
- | + | ||
- | class Chat { | + | |
- | id: Integer | + | |
- | | + | |
- | | + | |
- | type: String | + | |
- | } | + | |
- | + | ||
- | Message *--- User | + | |
- | Message *--- Chat | + | |
- | + | ||
- | @enduml | + | |
- | </ | + | |
===BeuthBot Project (One Git Repository)=== | ===BeuthBot Project (One Git Repository)=== | ||
Zeile 196: | Zeile 166: | ||
> Having this project organized with submodules makes it also easier to have and organize multiple **distributions** of this project. It further allows us having a global state / version of the BeuthBot. | > Having this project organized with submodules makes it also easier to have and organize multiple **distributions** of this project. It further allows us having a global state / version of the BeuthBot. | ||
+ | |||
==Default Ports of Services== | ==Default Ports of Services== | ||
Zeile 229: | Zeile 200: | ||
https:// | https:// | ||
+ | |||
+ | The deconcentrator uses different NLU processors to compare their results and tries to choose an best fitting answer. The NLU processors like RASA must know their domain on their own. The deconcentrator simply compares the confidence score of the intents given from the processors and returns the intent with the highest score. | ||
+ | |||
+ | ==Functionality== | ||
+ | |||
+ | <uml> | ||
+ | @startuml | ||
+ | |||
+ | participant " | ||
+ | |||
+ | box " | ||
+ | participant " | ||
+ | participant " | ||
+ | participant " | ||
+ | participant " | ||
+ | participant " | ||
+ | end box | ||
+ | |||
+ | GW -> DC: request\nwith message | ||
+ | activate DC | ||
+ | DC -> DC: create and fill queue | ||
+ | DC -> PQ: run | ||
+ | activate PQ | ||
+ | PQ -> RP: (async) request | ||
+ | activate RP | ||
+ | PQ -> P1: (async) request | ||
+ | activate P1 | ||
+ | RP -> PQ: interpretation | ||
+ | deactivate RP | ||
+ | PQ -> P2: (async) request | ||
+ | activate P2 | ||
+ | P1 -> PQ: interpretation | ||
+ | deactivate P1 | ||
+ | P2 -> PQ: interpretation | ||
+ | deactivate P2 | ||
+ | PQ -> DC: all\ninterpretations | ||
+ | deactivate PQ | ||
+ | DC -> DC: filter out\nbest intent | ||
+ | DC -> GW: response\nwith intent | ||
+ | deactivate DC | ||
+ | |||
+ | @enduml | ||
+ | </ | ||
+ | |||
+ | ==processor-queue.js== | ||
+ | |||
+ | For every incoming message the deconcentrator creates a new `ProcessorQueue` (defined in `processor-queue.js`) and adds all available processors to it. When calling the `.interpretate(message)` function of the queue it starts requesting the processors for an interpretation. The number of asynchronous requests can be set with the `numOfSynchronProcessors` property of the queue. | ||
+ | |||
+ | ==processor.js== | ||
+ | |||
+ | Defines the interface of a NLU processor. | ||
+ | |||
+ | ==API== | ||
+ | |||
+ | The following lists the resources that can be requested with the deconcentrator API. | ||
+ | |||
+ | Request life sign. | ||
+ | |||
+ | < | ||
+ | GET | ||
+ | </ | ||
+ | |||
+ | Answer: | ||
+ | |||
+ | < | ||
+ | Hello from BeuthBot Deconcentrator: | ||
+ | </ | ||
+ | |||
+ | Request interpretation of message. | ||
+ | |||
+ | < | ||
+ | POST http:// | ||
+ | </ | ||
+ | |||
+ | ==Request Schema== | ||
+ | |||
+ | < | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Whereas the specification of the min_confidence_score and theprocessors is optional. If not minimum confidence score is given a default one is used (by now this is 0.8). For now there is only the usage of RASA implemented so there is no effect of specifying the processors property. | ||
Model of an incoming message. | Model of an incoming message. | ||
Zeile 242: | Zeile 298: | ||
</ | </ | ||
- | Model of an answer | + | ==Response Schema== |
+ | |||
+ | The response for a successfully processed request to the deconcentrator contains the following information. | ||
+ | |||
+ | < | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Model of an answer. | ||
<uml> | <uml> | ||
Zeile 281: | Zeile 373: | ||
@enduml | @enduml | ||
</ | </ | ||
+ | |||
+ | The response for a unsuccessfully processed request to the deconcentrator or when an error occures contains the following information. | ||
+ | |||
+ | < | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==Requirements Analysis deconcentrator.js== | ||
+ | |||
+ | * /DCF100/ The deconcentrator responds to incoming POST requests by delegating the message to a collection of NLU processor which try to interpretate the given message | ||
+ | * /DCF101/ The deconcentrator accepts incoming messages as defined via the Request Schema | ||
+ | * /DCF102/ The deconcentrator sends answers as defined via the Response Schema | ||
+ | * /DCF103/ The deconcentrator answers with proper messages for occuring errors | ||
+ | * /DCF104/ New NLU processors muss be easy to integrate | ||
+ | * /DCF105/ The deconcentrator has a default value for the minimum confidence score | ||
+ | * /DCF106/ The deconcentrator has a default value for the list of processors | ||
+ | * /DCF107/ The minimum confidence score can be set globally within the Dockerfile | ||
+ | * /DCF108/ The list of processors to be used can be set globally within the Dockerfile | ||
===Deploying on Virtual Machine=== | ===Deploying on Virtual Machine=== | ||
Zeile 305: | Zeile 418: | ||
$ docker-compose up -d | $ docker-compose up -d | ||
+ | </ | ||
+ | |||
+ | ==Contents of .env file== | ||
+ | Following lists the contents of the .env file of the BeuthBot project. Note that the value for WEATHER_API_KEY has been removed for security reasons. | ||
+ | |||
+ | < | ||
+ | # deconcentrator | ||
+ | RASA_ENDPOINT=http:// | ||
+ | |||
+ | # gateway | ||
+ | DECONCENTRATOR_ENDPOINT=http:// | ||
+ | REGISTRY_ENDPOINT=http:// | ||
+ | |||
+ | # registry | ||
+ | MENSA_ENDPOINT=http:// | ||
+ | WETTER_ENDPOINT=http:// | ||
+ | |||
+ | WEATHER_API_KEY= | ||
+ | </ | ||
+ | |||
+ | ==Contents of docker-compose.yml file== | ||
+ | Following lists the contents of the docker-compose.yml file of the BeuthBot project. | ||
+ | |||
+ | < | ||
+ | version: ' | ||
+ | |||
+ | services: | ||
+ | |||
+ | # === ----------------------------- | ||
+ | gateway: | ||
+ | build: gateway | ||
+ | restart: unless-stopped | ||
+ | links: | ||
+ | - deconcentrator | ||
+ | - registry | ||
+ | ports: | ||
+ | - 3000:3000 | ||
+ | environment: | ||
+ | - DECONCENTRATOR_ENDPOINT | ||
+ | - REGISTRY_ENDPOINT | ||
+ | |||
+ | # === ----------------------------- | ||
+ | deconcentrator: | ||
+ | build: deconcentrator-js | ||
+ | restart: unless-stopped | ||
+ | links: | ||
+ | - rasa | ||
+ | ports: | ||
+ | - 8338:8338 | ||
+ | environment: | ||
+ | - RASA_ENDPOINT | ||
+ | |||
+ | # === ----------------------------- | ||
+ | registry: | ||
+ | build: registry | ||
+ | restart: unless-stopped | ||
+ | links: | ||
+ | - mensa | ||
+ | - weather | ||
+ | ports: | ||
+ | - 9922:3000 | ||
+ | environment: | ||
+ | - MENSA_ENDPOINT | ||
+ | - WETTER_ENDPOINT | ||
+ | |||
+ | # === ----------------------------- | ||
+ | rasa: | ||
+ | image: rasa/ | ||
+ | restart: unless-stopped | ||
+ | ports: | ||
+ | - 5005:5005 | ||
+ | volumes: | ||
+ | - ./ | ||
+ | command: | ||
+ | - run | ||
+ | - --enable-api | ||
+ | - --cors | ||
+ | - " | ||
+ | duckling: | ||
+ | image: rasa/ | ||
+ | restart: unless-stopped | ||
+ | ports: | ||
+ | - 8000:8000 | ||
+ | |||
+ | # === ----------------------------- | ||
+ | mensa: | ||
+ | build: mensa_microservice | ||
+ | restart: unless-stopped | ||
+ | ports: | ||
+ | - 9950:8000 | ||
+ | |||
+ | # === ----------------------------- | ||
+ | weather: | ||
+ | build: weather_microservice | ||
+ | restart: unless-stopped | ||
+ | ports: | ||
+ | - 9951:7000 | ||
+ | environment: | ||
+ | - WEATHER_API_KEY | ||
</ | </ | ||
Zeile 325: | Zeile 537: | ||
</ | </ | ||
- | Current output of `docker ps` on virtual machine: | + | ==Contents of .env file== |
+ | Following lists the contents of the .env file of the telegram-bot project. Note that the value for TELEGRAM_TOKEN has been removed for security reasons. | ||
+ | |||
+ | < | ||
+ | GATEWAY_ENDPOINT=http:// | ||
+ | TELEGRAM_TOKEN= | ||
+ | </ | ||
+ | |||
+ | ==Contents of docker-compose.yml file== | ||
+ | Following lists the contents of the docker-compose.yml file of the BeuthBot project. | ||
+ | |||
+ | < | ||
+ | version: ' | ||
+ | services: | ||
+ | telegram-bot: | ||
+ | build: . | ||
+ | restart: unless-stopped | ||
+ | environment: | ||
+ | - GATEWAY_ENDPOINT | ||
+ | - TELEGRAM_TOKEN | ||
+ | </ | ||
+ | |||
+ | ==Current output of `docker ps` on virtual machine:== | ||
< | < | ||
Zeile 339: | Zeile 573: | ||
</ | </ | ||
+ | Both projects contains a update.sh file which can be used to fast update the projects. | ||
====Requirements==== | ====Requirements==== | ||
+ | |||
+ | **Funktionale Anforderungen: | ||
+ | |||
+ | ''/ | ||
+ | |||
+ | ''/ | ||
+ | |||
+ | ''/ | ||
+ | |||
+ | ''/ | ||
+ | |||
+ | ''/ | ||
+ | |||
+ | ''/ | ||
+ | |||
+ | ''/ | ||
+ | |||
+ | ''/ | ||
+ | |||
+ | **Nicht-Funktionale Anforderungen: | ||
+ | |||
+ | ''/ | ||
+ | |||
+ | ''/ | ||
+ | |||
+ | ''/ | ||
+ | |||
+ | ''/ | ||
+ | |||
+ | ''/ | ||
+ | |||
+ | ''/ | ||
===Persistence=== | ===Persistence=== | ||
Damit der Benutzer sich selbst nicht ständig wiederholen muss, wird ihm die Möglichkeit geboten, seine Vorlieben zu speichern. Als Datenbank haben wir uns für die MongoDB entschieden. | Damit der Benutzer sich selbst nicht ständig wiederholen muss, wird ihm die Möglichkeit geboten, seine Vorlieben zu speichern. Als Datenbank haben wir uns für die MongoDB entschieden. | ||
+ | |||
+ | <uml> | ||
+ | @startuml | ||
+ | actor " | ||
+ | rectangle " | ||
+ | package " | ||
+ | rectangle " | ||
+ | package " | ||
+ | rectangle " | ||
+ | database " | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | U -down-> TGB | ||
+ | TGB -right-> GW | ||
+ | GW -left-> TGB | ||
+ | |||
+ | GW -up-> DBC | ||
+ | DBC -down-> GW | ||
+ | |||
+ | DB_NAME -right-> DBC | ||
+ | DBC -left-> DB_NAME | ||
+ | @enduml | ||
+ | </ | ||
===Cache=== | ===Cache=== | ||
Zeile 461: | Zeile 752: | ||
====Goal for end of semester==== | ====Goal for end of semester==== | ||
+ | |||
+ | Following diagram demonstrates the current state of the working component of the BeuthBot. | ||
Current State: | Current State: | ||
Zeile 497: | Zeile 790: | ||
</ | </ | ||
- | Target State: | + | Following diagram demonstrates the target state of the working component of the BeuthBot. |
<uml> | <uml> | ||
Zeile 519: | Zeile 812: | ||
rectangle " | rectangle " | ||
rectangle " | rectangle " | ||
- | rectangle "NEW_SER_1" as NS1 | + | rectangle "schedule" as NS1 |
- | rectangle "NEW_SER_2" as NS2 | + | rectangle "scraper" as NS2 |
+ | rectangle " | ||
} | } | ||
} | } | ||
Zeile 550: | Zeile 844: | ||
RE -up-> NS2 | RE -up-> NS2 | ||
NS2 -down-> RE | NS2 -down-> RE | ||
+ | RE -up-> NS3 | ||
+ | NS3 -down-> RE | ||
DB_NAME -right-> DBC | DB_NAME -right-> DBC | ||
Zeile 568: | Zeile 864: | ||
-- Implementation -- | -- Implementation -- | ||
- | [Persist user preferences] as [I1] lasts 30 days and starts 5 days after [C]'s end | + | [Persist user preferences |
- | [Cache microservices responses] as [I2] lasts 30 days and starts 5 days after [C]'s end | + | [Cache microservices responses |
- | [Transform scraper microservice] as [I3] lasts 30 days and starts 5 days after [C]'s end | + | [Transform scraper microservice |
- | [Adjust weather microservice] as [I4] lasts 30 days and starts 5 days after [C]'s end | + | [Adjust weather microservice |
- | [New course schedule microservice] as [I5] lasts 30 days and starts 5 days after [C]'s end | + | [New course schedule microservice |
[C] -> [I1] | [C] -> [I1] | ||
[C] -> [I2] | [C] -> [I2] | ||
Zeile 578: | Zeile 874: | ||
[C] -> [I4] | [C] -> [I4] | ||
[C] -> [I5] | [C] -> [I5] | ||
+ | [D] is 80% completed | ||
[I1] is 0% completed | [I1] is 0% completed | ||
[I2] is 0% completed | [I2] is 0% completed |