Merken

"It's about time to take your medication!" or how to write a friendly reminder bot ;-)

Zitierlink des Filmsegments
Embed Code

Automatisierte Medienanalyse

Beta
Erkannte Entitäten
Sprachtranskript
thank you everybody and welcome to my talk about time taking medication or how to write a friendly reminder elsewhere that we
understand normally and more like a data scientist guys and yet unless Europe I in Berlin I give a talk about how you can extend um I learn don't estimator so quiet Math these stats talker and difficult 15 people thought OK so this year I try something different and well happen this the better it is so surely the question that all have this why would anyone right check bought and there's a little story behind it so a friend of mine and I was diagnosed with diabetes solution we all know that it is you have to take insulin the whole time and she said that you suggests 2 kinds of insulin just 1 you take before you eat something while you eat something and there's the the long acting insulin this is something you have to take it at this specific at time during the day and his edits he's always like forgetting about this are taking it 1 hour to later to earlier than that of course he said alarm on a smartphone but it would be really cool if someone would somehow remind him just like use chat or recall him or somehow remind him and then the idea was born of the white wine that's right a little box around that uses so will talk or a Facebook or any kind of checking engine and reminds him to actually please take long-acting insulin now and to also waits for answer that he really did and otherwise like reminded me again and all over and I thought well it's also good for me it's not only that mn like helping a friend it's also familiar because it's a minute to good use case to actually start at learning something new learning more about event-driven as synchronous programming something rest is real high right now I mean everyone's talking about a single I would a lot of a lot of talks about a single I don't know if you using to talk by the class about the distributed hash table which wasn't think really great talk about a single so it took this as like use case that will learn something about it all the little bit about x and P and about how 1 can write it like that people will have because in the end I used uh um Google Hangouts to actually implement and of course you have to help a friend so so the the the 1st thing I wanna talk about is what is event-driven programming and what is what it what it has to do with a synchronous programming so event-driven programming this is the definition of Jessica Mäkelä from the patristic network programming essentials intervention program program flows is determined by external events it is characterized by an eventual and the use of callback to trigger action when events happened so this is basically a the definition and it's a state of any kind of event an event could be like a user triggers an action or a message is received over a network and then you have pre-defined actions the so called callbacks that at then triggered and that actually and do something and in most cases this is implemented as a kind of event will present as the main that listens for events and triggers the call back and Kullback such as continuation so it's just like what do we do if I get a message or if I have received something and um events from programs can be single-threaded but also modified architecture exists due to the the big deal in Python so from a single mostly is single-threaded but you could also imagine that you have for each called bank you could start a new and you get a new threat of something then you would have more like a multithreaded adventure program but this is mostly not it's not what it's about and most implementations and I to differentiate this a little bit from what is blocking and nonblocking you could think of intervention program itself is purely from a definition could be blocking or could be non blocking instance if you're if you're have a query and you click on the on the on the bottom than event is triggered some action is going be processed and during that action your whole could be blocking and this sometimes things you see it on Windows for instance that the whole we blocks in is unresponsive or a while evaluating the this call that could be non-blocking so that other things can happen at the same time or for instance another example would be some kind of 3 D computer game I mean while the the engine is waiting for user input it's still calculating the physics engine and its updating the so what is a synchronous programming then asychronous all or none blocking I was a form of input output processing that permits other processing to continue for the transmission has finished so this is the also be light like uh form of cooperative multitasking because you you kind of at certain points in in the during the execution you kind of give away at the the process to other things and to let its you have to be given away so what other task can use your you can use to processor so but it's this cooperative in
contrast to primitive in the sense that it's really at specific points and we will see that later and the concept can also be implemented as an event in since that time a picture says more than 1 thousand words so while the have this graphics so if we have a program something really simple program that basically consists of 3 tasks and the tasks and have different colors and if you see the gray boxes I actually like waiting times when the the task reads in a file or maybe weights for a network socket or message on event by the side of the user then it kind of is in it's working to weight and the total time is instead of the of the program is the sum of all those blocks so in multi-threaded you would like comically put each task in own threat and um execute them in in parallel so this is something and you would not do like this in in Python you were more let's use processes because of the of the interpret a lot but in this case to the important and the point here is that you still have the great blocks and the tasks are still waiting and until yeah until some some I always ready for instance and in a synchronous there instead you will have only 1 thread again but during the Great blocks it's actually a switch to another tasks and something is done so here we start with the blue then during the waiting time here we start working on task number 2 and even and task number 1 until we have customer 3 because here we also have a wedding block and then it's in a concurrent way and in a way that can be a like a deterministic told so it could be that the colors could also change on the right side and I think this is this is an important point so concurrent inventor programming you don't know beforehand what the path the threat to your program is going to be so when to actually use a synchronous inventor programming if you have many tasks of course you should have at least 2 other ways make really sense if and then the tasks are largely independent so this is just no much in the communication between 2 draft you could imagine if 2 tasks are the whole time talking to each other and this could be difficult then of course when you when you have to wait for I when they normally would block and you think you you could do during that time you could do other things and if your tasks share a lot of mutable data model which to be need to to be sitting 2 if you do it in a multi-threaded a multiprocessing way is also a like indicated it you could think about using something as strings and also something event driven and this is especially for network application and user interfaces save that interfaces interfaces like natural you that you have there you use a synchronous event-driven programming so some examples of on a show to come to better 58 here so when you see it easy tasks that the just fetch some you else and print them and check the letter time so how would this look like in a single thread version so we have a sound just a list we set our timer and for East we used to you late to request the host and then the printed we also do a little transformation and make it a bit more interesting we just make in the other cases and print the 1st 20 characters and the host will we got the web page from and print the elapsed time so this would be a like a normal thing afraid program in Python how you would doing and of course what here is like the blocking so here is actually the rate law can be seen before now a diagram because we're waiting here for the request to be fulfilled in and wait for getting a the the request and also here we wait to like read their HTML so now let's a model for the way here gets only people in the more complicated so we also do and just a repressed um and the reading in in 1 of the function and now we generate some some threats so each task is just now a threat and it's the listed in uh the chops list and we set here where there would be our time so I skipped all head of creating that has the threats then for each chop started we wait until the joint so until the finished and we see that there's there was a up so this is uh just more or less a direct transfer of translation Oficina for the program in a multithreaded program so how would it look like in asychronous dilemma used futurist at which is right now only winnable for Python 2 but they're just working on a migration has 3 so here gets
a bit more complicated because we kind of have to separated different parts of the program much more and we use now Kolbeck so we have here capitalized functions OK we just use capitalize and the strip it down to 2 at 20 characters and and reprint elapsed time now here's the interesting part so for East host in almost list we get the page and this is none of this is now a Non blocking operations real directly return and will get us a different result in a different result is um what in in 5 minutes and I was called the future so it's a it's actually just a proxy for future results and you can say what should happen if 2 result is retrieved and this is what you do with that at call back so you say if I have this this is the different result ever becomes real result then please print they're called the print capitalized function with it and this is the registered follow callback and then we add everything to list and then we say OK and now for all this if they're all before all different results actually fire then we also want the fire the print elapsed time function and we call it with the task react the main function so this is now the eventual so to say so we say the run this loop and run the that the function and to receive yeah that it didn't work but what you can see from this example is it gets really complicated so adding the callbacks it's like you have to think of here have different result and callbacks and if those fired like through them in and another 1 so it did really complicated and this is also a statement that the defined also owns that supposedly once said so I find founded on the net this quote and then it's never lies right so it requires superhuman discipline to write readable called in callbacks and if you don't believe me look at any piece of javascript code and so the question is how would this now look if you would for instance use case and all so um in a single you would use to across the quarantine security in so how many of you know what a coroutine is so OK it's in most so it's just a function that you can like it's not a function of routine is like more general idea of a function but you can stop at that 1 point return in and come back and this year I used the ADI 0 HEP which is based on a single cell and at that point the yield from the repressed and um
so we give away the execution here for other tasks to do something at the waiting time but what we get in return is the the real responsible and if the the function here and so you you from if the function of the yield from returns a future you wait until the future gets like realized or if it's a quarantine until the next and results generated and then reused from the response and read and be directly get paged him l and the now for each and host host we have a task list again we append this print page function we get the event loop and we run the task until they're done and we also see the speed up so this the the the point here is that using a single I all and avoiding callbacks in this example it's much more readable and a much more looks like the the single threaded version actually um and uh yeah it's it avoids this complicated process of of of callbacks so I think this gets you like a good idea about as synchronous eventually programming so and now back to our actual task so how do you know what based on this so the idea is we modify our friend at 8 PM as agreed about taking his long acting insulin using Google talks or who hang out then we wait 20 minutes for reply then we ask again did you really take it and ask again after another time the through the whole time to check if there a message which stopped or is equal to yes if we get this message should praise him we say yeah well done a good job and if the message is in any other 2 2 yes we we just say that we just ignore it of course glycolysis and something like that I didn't get it yeah after having 3 times a times faster told the ones and we give up message like OK now I'm giving up the and to ask again so when when actually stating something like this it's for me at least it was helpful
to come out 1st that the with the statecraft because what we actually doing with the extraction is that we changing between different states and they're also libraries for this in in Python and but that before before below they just went in OK so how many states to actually have to make it so you have to make do with those solutions and best possible so during the during day we're in in no message sent states assisting the states and what happens if for instance that any kind of message so this is the event from uh my body from a friend that at that time then we just do nothing so to avoid being steady for instance right suggest before I even have passed I mean this is a situation to consider and at so at the event at 8
PM we send a message with no and message sent state so if he replies then with the yes we send OK that's good the prize and go back after another 20 minutes we ask again and I think you get the idea a until that point and there's also if you then repeats with the yes it's still OK but after 1 hour was an OK if you've done not so good and uh and we give up and this is how it can be translated program but which protocols are actually used so on 1st I thought about the already started to implement it in XMP piece x and p is the Extensible Messaging and Presence Protocol which is based on XML it or formerly was known as chopper and there Google talk so cheap talk used it but um it's was he protected quite lately so we switched to to hang out with is proprietary protocol which is yet not that good even Facebook uh they had an x and PPI AP until just recently made 2015 ready made when it stops it so this is not a good but still she talking is it's working and then melted implementation for this and so um if you wanna ever do something that somebody I would recommend this the gaps and that the library and you also get a lot of good documentation voted but since it was deprecated and a switch to to Google Hangouts as it provided for a particle and a really good library that was this kind of this is a reverse engineering of uh Google Hangouts is hang out by Tom drier and the yeah it's quite active project at the moment and it also already provides uh um chat clients the interactive chat line and there's a lot of what's already based on on hang up so this is a really interesting project so the implementation the to our can be found on the 2 younger that site that I look for a website but the younger group did have a account and I want stress so just shows some the code examples so where it all starts like the running and of the default class so it's really not that much called actually so you can later just look it up but so the interesting part is that that you that's a client is now the the hang up protocol client and you say what should happen on a connect to connect different to you connect different functions to the events that have been called the SOAP server power and uh we have you did the event get the 2nd alarms it's just to get the function that calculates from now to work next 8 PM today or tomorrow and uh and says later I'm going to call the function set the alarm and then it's like calling that the Kinect function of the of the client to do some more registries regulatory staring off uh called so just to set the alarm function look like the the more interesting so here's the message as we get uh the conversation with the recipient so because I mean you could check to to to many people at the same time we the yield from the message this is also again a point where you give away the execution to do something others like waiting for an answer or a 4 doing other kind of network uh and transmission we sent to the state that we now and in the last state we sleep and since we use from a single I O sleep here is also we give away the execution to other tasks that can be uh ran concurrently and here it's just 3 times uh I'm asking and here is the beginning of class the giving out and in the end we just set the timer city back to the next time and is and think they're the code is like quite easily readable and it avoids the a more less avoids the registering a lot of callbacks on some kind of different results like you would have done it maybe with twisted and there no handling message so on events when the the messages received we get from the message to the Congress conversation we get the user idea we get the textbook was actually sent we check if the use ideas from equal to just say no to the recipient idea to the 1 we wanna talk we check if the text is positive a positive answer and if everything is fulfilled here and right stated is positive and it's from from our body we just send the message that's great and go back in the and of defaults and ask because false states so we go back to the initial state in our state diagram alright that much about the the source code is that you can just check it up online and maybe 1 more thing about authorization if you write about like this you don't want like provide your credentials and put it somewhere in the files so this is where it all the and the patient was then it comes into play and this allows that you as a resource on the uh if 2 special special rights to and to you applications and it works by using user told for how does this work your application all it wants to do is to use your good counter actually sent some messages and it doesn't need to know all your contacts contacts is just sending messages so if requests told with this goal of sending a message that the you get a you well this is where you can display to the user the system basically you know all notices kind of screens that then just click except and um you could authorization code back and you can use this code to get a and um With this told me your application can then without knowing your passwords them off your Google uh used to Google API to you have to to to send messages over hang out for or the other talk or rights and so on just a picture to show how it looks like the Indians and the youngsters stood easy use use case but the rock and the engine is quite happy with the
uh thanks to Tom trials so this was that the guy from hang-ups them who also helped me a bit and the have all the pictures I took our creative commons and thank you for your attention that yeah so I have
things we talk I actually have to to small questions like what you thought of implementing this some of the communications support site for example telegram what's have all this kind of stuff but for have you thought of other and communications support support from thing else like what's have faced telegram argue implementing and
and the other question is I actually thought of making something like this uh having chronic disease myself to force to just remember stuff and but what I felt it would be really interesting and this would be to have some kind of AI or machine learning to actually but for having the computer knowing when I'm working to forget to take you through this kind of stuff so is it some kind of like do you have in the future because I would be really interesting but stating that they had I 0 I also thought about this because in mean now I'm out get the messages so when he took it and maybe it would be guaranteed if it's more easy to forget right and maybe on a party or whatever and not just at the right time and like you don't do anything and of course you could then run a lot of statistical analysis on it and an instance of 5 August data scientists of course if you would have a lot of information about this you could to some statistics you could even predict that on the weekend uh and yet but on the other hand is always but private information right because it yet but I think this is a is a good idea and I think it the basic ideas so you to your 1st question could also be easily done on Facebook and so there a lot of libraries if you start looking for it and also a lot of of sport libraries and that could help with the finding the right answers making may be the conversation a lot more interesting so there is stuff like this I wanted keep through a simple as a 1st try but yet no 1 could could definitely build on it in more questions hi and yeah that's really great happy thought putting any kind of link back to some maybe something physical like I mean you're pack all so that you both have proof as well as his yes command the has taken this into so much so so you say yes and they had to open a packet that moved to switch and that was recorded the et al more thinking about and say people outside this need to be reminded state templates have you thought of expanding it in that kind of way so far we have not really work so I so it's so I mean in the in city well there yeah there really keen on making sure that people do actually take that happens as opposed to just saying yes that's taking them so have you thought of expanding it so that you can have a switch that's all that someone and open a pillbox et al Qaeda in our isn't yeah I mean then gets of course more complicated you would need to have the device for what those insulin pumps for instance and some already have some yup technique unit and what if 1 could access protocol and then you could maybe even yeah he could that connect his smartphone to that device and I know that there's a lot going on for instance the the the measurement of the blood sugar is now I'm just like 3 month ago there was a new device from from the people which is constantly like measuring your blood sugar and you have it on your own right arm and then you can just read adults and 1 them 2nd by 2nd basis which is much better than doing it the conventional way and of course 1 could like trigger back so if you took it then you will also get from this and sort that the blood sugar goes down and so it there's endless possibilities but this would and then it would need to like is what that both of them in commercial something was just from use case but I think it's definitely possible in the technical sense and 1 could follow up on that more questions right and that was fascinating thank you very much again thank thank you thank you thank you
Bit
Punkt
Prozess <Physik>
Extrempunkt
Synchronisierung
Computeranimation
Metropolitan area network
Minimum
Bildschirmfenster
Analytische Fortsetzung
Funktion <Mathematik>
Umwandlungsenthalpie
Datennetz
Güte der Anpassung
Abfrage
Systemaufruf
p-Block
Ein-Ausgabe
Multitasking
Ereignishorizont
Angewandte Physik
Rechter Winkel
Programmschema
Bildschirmsymbol
Smartphone
Message-Passing
Chatbot
Instantiierung
Aggregatzustand
Tabelle <Informatik>
Facebook
Subtraktion
Quader
Gruppenoperation
Klasse <Mathematik>
Mathematisierung
Implementierung
Ereignisgesteuerte Programmierung
Abenteuerspiel
Data Mining
Task
Bildschirmmaske
Computerspiel
Hash-Algorithmus
Thread
Coprozessor
Optimierung
Ereignishorizont
Gammafunktion
Schätzwert
Datentransfer
Statistische Analyse
Gasströmung
Computerarchitektur
Bit
Gewichtete Summe
Punkt
Datenparallelität
Versionsverwaltung
Kartesische Koordinaten
Wärmeübergang
Extrempunkt
Synchronisierung
Computeranimation
Richtung
Metropolitan area network
Translation <Mathematik>
Kontrast <Statistik>
Parallele Schnittstelle
Haar-Integral
Schnittstelle
Lineares Funktional
Datennetz
Stichprobe
p-Block
Ereignishorizont
Gefangenendilemma
Socket
Message-Passing
Zeichenkette
Telekommunikation
Gewicht <Mathematik>
Quader
Zahlenbereich
Web-Seite
Ereignisgesteuerte Programmierung
Task
Informationsmodellierung
Task
Migration <Informatik>
Thread
Optimierung
Ereignishorizont
Schreib-Lese-Kopf
Benutzeroberfläche
Datenmodell
Einfache Genauigkeit
Mailing-Liste
Elektronische Publikation
Kreisbogen
Einfache Genauigkeit
Wort <Informatik>
Kantenfärbung
Normalvektor
Logik höherer Stufe
Master-Gleichung
Resultante
Proxy Server
Bit
Subtraktion
Punkt
Gewicht <Mathematik>
Prozess <Physik>
Hochdruck
Versionsverwaltung
Code
Computeranimation
Homepage
Eins
Task
Metropolitan area network
Loop
Message-Passing
Mailing-Liste
Task
Code
Total <Mathematik>
Statistische Analyse
Optimierung
Nichtlinearer Operator
Lineares Funktional
Befehl <Informatik>
Vererbungshierarchie
Computersicherheit
Singularität <Mathematik>
Systemaufruf
Mailing-Liste
Gleitendes Mittel
Ereignishorizont
Endogene Variable
Bitfehlerhäufigkeit
Mereologie
Bildschirmsymbol
Message-Passing
Instantiierung
Resultante
Offene Menge
Umsetzung <Informatik>
Punkt
Momentenproblem
Gruppenkeim
Kartesische Koordinaten
Google Talk
Aggregatzustand
Computeranimation
Metropolitan area network
Client
Standardabweichung
Reverse Engineering
Verweildauer
Druckertreiber
Default
Gerade
Große Vereinheitlichung
Konfigurationsdatenbank
Lineares Funktional
Gruppe <Mathematik>
Datennetz
Reverse Engineering
Güte der Anpassung
Quellcode
Ereignishorizont
Gruppenoperation
Rechter Winkel
Client
Server
Projektive Ebene
Normalspannung
Ext-Funktor
Message-Passing
Statechart
Aggregatzustand
Instantiierung
Web Site
Facebook
Subtraktion
Ortsoperator
Klasse <Mathematik>
Implementierung
Code
Task
Task
Programmbibliothek
Passwort
Optimierung
Ereignishorizont
Gammafunktion
Implementierung
Touchscreen
Leistung <Physik>
Autorisierung
Protokoll <Datenverarbeitungssystem>
Datentransfer
Physikalisches System
Elektronische Publikation
Loop
Mereologie
Partikelsystem
Einfügungsdämpfung
Instant Messaging
Informationssystem
Systemprogrammierung
Telekommunikation
Web Site
Bit
Jensen-Maß
Computeranimation
Facebook
Umsetzung <Informatik>
Statistik
Protokoll <Datenverarbeitungssystem>
Template
Physikalismus
Statistische Analyse
Computer
Binder <Informatik>
Quick-Sort
Arithmetisches Mittel
Einheit <Mathematik>
Rechter Winkel
Beweistheorie
Basisvektor
Programmbibliothek
Information
Algorithmische Lerntheorie
Smartphone
Message-Passing
Einflussgröße
Aggregatzustand
Instantiierung

Metadaten

Formale Metadaten

Titel "It's about time to take your medication!" or how to write a friendly reminder bot ;-)
Serientitel EuroPython 2015
Teil 61
Anzahl der Teile 173
Autor Wilhelm, Florian
Lizenz CC-Namensnennung - keine kommerzielle Nutzung - Weitergabe unter gleichen Bedingungen 3.0 Unported:
Sie dürfen das Werk bzw. den Inhalt zu jedem legalen und nicht-kommerziellen Zweck nutzen, verändern und in unveränderter oder veränderter Form vervielfältigen, verbreiten und öffentlich zugänglich machen, sofern Sie den Namen des Autors/Rechteinhabers in der von ihm festgelegten Weise nennen und das Werk bzw. diesen Inhalt auch in veränderter Form nur unter den Bedingungen dieser Lizenz weitergeben
DOI 10.5446/20225
Herausgeber EuroPython
Erscheinungsjahr 2015
Sprache Englisch
Produktionsort Bilbao, Euskadi, Spain

Technische Metadaten

Dauer 30:29

Inhaltliche Metadaten

Fachgebiet Informatik
Abstract Florian Wilhelm - "It's about time to take your medication!" or how to write a friendly reminder bot ;-) The author shows how to use the [SleekXMPP] library in order to write a small chatbot that connects to Google Hangouts and reminds you or someone else to take medication for instance. The secure and recommended OAuth2 protocol is used to authorize the bot application in the [Google Developers Console] in order to access the Google+ Hangouts API. The author will elaborate then on how to use an event- driven library to write a bot that sends scheduled messages, waits for a proper reply and repeats the question if need be. Thereby, a primer on event-driven architectures will be given.
Schlagwörter EuroPython Conference
EP 2015
EuroPython 2015

Ähnliche Filme

Loading...