New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TODO's before queries can be used in the Discord bot #109
Comments
created Information class in previous commit
I’ll work on this but I can’t make any promises about how fast. I will probably be unlikely to be able to work on it this weekend due to writing an analysis and game design document, for example :( maybe my current availability is more as editor rather than core programmer right now |
Ok. If I understand well, MusicSheetMaker will do what Responder did? |
Oh sorry it must be confusing 😓 So Communicator will replace Responder.
As for the Song, Parser objects, right now they are properties of Responder (self.song, self.parser). But I feel like they didn’t belong to responder/communicator specifically. So the Music Sheet Maker will have those properties instead:
```
class MusicSheetMaker:
self.parser
self.communicator
self.song
```
etc.
Oh as for the communication between the bot and our program, fundamentally it’s like this:
Music Cog <-> Sky Python Music Sheet Maker
Inside That-Sky-Bot, there is a sub folder with the whole sky-python-music-sheet-maker in it
|
Ok, so, to resume:
We can consider that music cog will ultimately be Alex’s responsibility. |
My drawing implies that:
Another solution, which contradicts my drawing, would be to force the bot/cog to use the Query/Reply structure directly. This is what I intended in the first place. Either by forcing it to instantiate Query and Reply directly from the communication module, or by instantiating it’s own Communicator, who will handle queries. So the question to be answered is: In any case... while on one hand we know which questions the Maker can ask the player, on the other we have to list all the possible questions the player can ask to the Maker. For questions that are not anticipated, we have 2 solutions:
|
Ohh initially I intended for the queries, replies (and other messages e.g. Information) to be between Maker and the Bot, like your second digram and in this description^^
Hehe you drew pictures to visualise it~ I like that. I still am really unsure on how to best structure the relationship between the Maker and the Bot though (e.g. where to put Parser and Communicator?) feel free to decide on that, whichever you feel is best from your diagrams. |
About Alex being in charge of the Music Cog, I think that’s fair and that’s what he intended too actually ^^ before I tried the prototype to test it. The thing is, we will need to provide very clear and concise documentation. On how to start a song, parse notes, pass on questions about key etc. (which is being done through queries now) I’m not going to just put the burden to you btw – I intend to stay on this project, I just can’t work on it as often 😭 |
Your school project goes first. Even though it may be enjoyable to work on two projects at once, to get some fresh air for your mind. You know, like a musician being in two music bands at the same time. For this reason only though! And remember that the second one is called “side project”.
That’s great because I started to write down a few lines of code and I naturally converged to the first solution, and then I realized that it would be silly to invent such an elaborate communication system if it were to use it internally only. So, a more symmetric system like the one you drew is better. But then we’ll have to make communicator as generic as possible, since it will be used by both parties. Actually, Communicator could be on the Maker side only, as a shortcut to generate queries. |
* Added a receive method to Communicator receive a Query * Added recipient.receive(self) to the send method of Query, to make the recipient receive the Query. Indeed, not forcing him to do so would require a completely different coding mechanism (using triggers, timeouts, etc, with the recipient periodically checking for any pending query) * Used the \_\_getattr\_\_ attribute to pass unknown methods to communicator. This way, a sender or recipient can handle queries in a transparent way (while in practice it passes them to its communicator, exactly as a person woul process a query through its brain) * Added recipient, owner attributes whenever needed, more to come; indeed the most important thing when handling question/answers is to know who speaks and to whom * changed a few method names * added arguments to the check_sender and check_recipient methods in Query so we can check the names against a list passed as an argument (useful to test if a Query is indeed addressed to you)
mmmhhh... For instance: song = await Questions.ask_text(self.bot, channel, ctx.author.... is nothing more than our Query() object! And: await channel.send( is nothing more than Information()! And: await channel.send(files=my_files) looks like a Reply! So the only thing to do is to feed these asynchronous routines (utils.Question, channel.send) content from our Query, Reply, and Information objects. |
Ahhh yes this is what I had in mind too!!
|
Oh I’m not sure, just logged onto website now to see comment (saw picture from email). Yeah I don’t know how to implement it, that was the system I had in mind though :D Haha I will focus on school project for now as you said, one document is approaching finished state now - but I do enjoy working on side projects though. |
Ok I think we are able to write a communicator class for the bot too (It's possible to make classes at the top of the Music Cog) so 2 communicator classes is possible |
I have lost 1 hour because the self.queries property of QueryMemory was a class instance instead of an object instance. Because of that, the memory was shared between different instances of communicators! To solve that, I explicitely written that self.queries = []
I'm going to get back to working on this next weekend, as a heads up 👍 |
Many improvements in communication.Memory to find queries.
Great ! Maybe should we organize a live chat so I can better answer your question on how things work so far. I am available between 7:00 AM and 9:00AM GMT on mon-rue, 6:00 AM and 8:00 AM (GMT) on wed-fri, and between 6:00 AM and 6:00 PM (GMT) on weekends. There are two things that bother me very much: 1/ I have the feeling that we have created something too complex. I am starting to wonder if what Alex meant by “make the question a model” was not simply the equivalent of utils.Question. 2/ the conversation (ie exchange of Queries) between bot and maker is artificial so far, since I am doing tests on a single command line program. Not only both parties are on the same machine, but the conversation is entirely sequential. Meaning that each party, after creating a Query (Query.send()), must call a method in the other party communicator (maker.communicator.receive) to force it to read the Query. The only other way around would be to use asynchronous programming (asyncio module). In this case, one party would sequentially emit queries, and store them inside a shared global variable, or maybe inside the other party. Let’s call this variable the mailbox. In the meantime, independently, the other party would periodically check its mailbox from time to time. And vice-versa. We could do these asyncio tests on the same machine. Actually I made a few tests but quickly encountered a new problem: prompt functions such as input() are not really compatible with asyncio, meaning that they halt the program. Anyway, these tests would make much more sense if the asynchronous communication took place between distant machines, between server (discord/bot/music-cog) and client (player/discord). |
Oh yes! How about a live chat on discord? I will be available on one of the weekend days. Hm ok 6am GMT is currently 5 pm here, how about 9am GMT on Saturday? I see about asyncio, I’ve never used it outside this before (my first encounter was in the music cog) it seemed frightening to me too haha^^
I understand this description though! |
Ok, I’ll send you a message the day before to confirm. |
Sure^^ 👍 it’s live text chat, to confirm?
|
Yes, we could use the chat channel of your discord Sky Music Maker account, or another temporary channel. |
That’s ok for Saturday at 9:00 GMT = 10:00 Paris = 20:00 Melbourne. |
Yep any channel is fine, sorry I didn’t get to respond yet^^ |
It was nice talking to you. Sorry I talked too much but I felt the need to report to you on what I did. In the meantime I have added a working script using asyncio. It does not use our program yet. |
No worries 😊 yeah it must have been hard working on it for two weeks without being able to communicate about it much 😓 I enjoyed chatting too.
Ok, I’m hoping to get to know the changes better today, going to run the puppet MusicSheetMaker and CommandLinePlayer
|
ok I managed to run through CommandLinePlayer and MusicSheetMaker, and I think I'm starting to understand the changes better now^^ some of the questions, such as |
Actually we could use asyncio without changing anything else, just by adding the async keyword before definitions and the await command before calls 😝. People sometimes do that to speed up execution (independent tasks are run concurrently) , but in our case we don’t have any time issue related to queries. So, the real question behind asyncio the question will be to use a mailbox concept instead of a puppet concept. I mean, instead of having two puppets pulling strings from each other (receive(), execute_queries()), they would be periodically checking their inbox for new messages to process. I have asked info to Alex about the urge to use asyncio.
Yes. |
Ah okay, I see Oh yeah but the input modes and song key need to be asked after parsing, e.g. —
A, D, E are calculated from the possible keys method determined by Parser. And:
The two options were determined by Parser, after the user has typed the notes. |
address TODOs listed in TODOs for Query, a new class for bot interaction #104
rewrite the methods from
responder.py
intocommunicator.py
rewrite the instructions. Maybe this should be done by parser??
write the music sheet maker's questions as queries, in the
create_queries()
method ofcommunicator.py
make sure Parser works with queries
determine if the use of asyncio is mandatory for the command line version to work
In music sheet maker, decide how to return the results of queries from one method to the overlapping one (the one which called this method), by returning Reply objects or directly doing Query.reply_to
check if the query_stock structure is adequate
address TODOs left in the code as comments
about the name 'Responder' or 'Communicator', any is fine. The problem is that Responder is not centred on communicating through Query messages.
The communicator/responder is what's between Parser and the outside. Right now, I feel that the current Responder class is still way too structured for only the command line — all of the
Responder.ask_to_select_mode()
ask_song_key
def ask_song_headers
etc. methods need to be written as each queries nowThe text was updated successfully, but these errors were encountered: