-
Notifications
You must be signed in to change notification settings - Fork 3
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
Runner state setting and getting #2
base: main
Are you sure you want to change the base?
Conversation
Thanks so much for the PR! I want to warn you that it will take me longer than normal (probably about two weeks) before I can review and comment on this, but I'm excited to do so once I get the chance! |
I'm having problems serializing and deserializing the compiled_yarn or the vm_instruction_stack. Which one makes sense to persist? Any examples (I am trying with protobuf's SerializeToString/ParseFromString, but doesn't work)?Any hints you could give me? |
Sorry, just saw this: |
I've expanded my state export with other attributes, including merging your changes. However, there's still something wrong with the state (see (this test)[https://github.com/mapto/YarnRunner-Python/blob/main/tests/test_shortcuts.py#L63] that fails on line 92). It seems that after loading the lines are not picking up from where they were left. Instead they restart. Could you give me a hand identifying what's the storage that I'm missing? Thanks! PS: I will now change the persistence to JSON, as it seems to be the format that's already partially used. However, it would be pointless if I am not capturing the complete state. |
Thanks for working on a first pass at this @mapto! I really appreciate you putting this forward, and look forward to working through it with you to get it merged. A couple of things:
Overall, I think, the major information that should be serialized in the save state should be:
The major information that should not be serialized is probably:
How do you feel about these suggestions? Do you feel comfortable making these changes? |
Thanks for the feedback! At a personal level, my team dropped out from the game jam, yet both our story writer and I are interested to continue to explore yarn. So this means I can continue to work on this PR, but will be able to dedicate less time in February. Now regarding solutions: Certainly agree that JSON is a better solution and I would readily do it the way you describe. However, I already tried serializing both the information you indicated as should and the one that you indicated as shouldn't and my test with shortcuts continues to fail, so I am sceptical that switching to JSON would take us any forward. Given that it appears to me that explicit state serialization seems to miss something that remains unidentified, I am wondering if it makes sense to try serializing with (pickle)[https://docs.python.org/3/library/pickle.html] which shouldn't leave any chances. Anyway, I'll try with JSON and if that same test continues to fail we can discuss that other option. |
Good news: a quick implementation with JSON passed the previously failing test. TODO: the hash function for version comparison and wider testing |
I'm putting forward a first suggestion of state manipulation that would allow persisting the story state externally, as discussed in Issue #1
I don't expect this solution to be accepted as it is, it's rather a discussion of the approach. I preferred constructor and repr() interface, because another save/load functions would have to export in/import from a complex data structure that would have to be represented in a format (new class or JSON, etc) that is yet to be introduced. The proposed approach is probably more pythonic, relying on built-in functions. Of course a more efficient way to export is to access the field values, rather than the repr() string. Yet, repr() enables the reflection pattern.
Also, my interpretation of state is rather naive:
Let me know what your thoughts are and I will adapt the solution.