beanlab / quest_framework

A Python framework for fault-tolerant workflows
1 stars 0 forks source link

Serialization #48

Closed easyasme closed 3 days ago

easyasme commented 1 month ago

Concept Historian passes records containing potentally non-JSON-serializable objects to MasterSerializer. MasterSerializer recursively traverses the record and replaces any objects that needs serialization with dictionary {_ms_type, args, kwargs}. Dictionary is passed to Blobstorage - simply stores and retrieves these dictionaries without any custom serialization logic - simple implementation.

Modified MasterSerializer - automatically serialize objects by capturing their class name and constructor arguments (args, kwargs). for deserialization - it can reconstruct the object by importing the class and calling its constructor with the stored arguments.

PersistenHistory - use MasterSerializer to serialize records before passing them to the blobstorage and to deserialize records after retrieving them

Historian, Blobstorage, workflowmanager - do not need to change

The test file has not been implemented yet; it will be added after confirming that I am on the right track.

easyasme commented 1 month ago

Modifications MasterSerializer - modified to return the object as-is if no custom serialization is registered.

Questions persistence.py - I noticed that await can't be used in the init method. I used asyncio.run for the deserialization process. Do you think this is an acceptable solution, or should I refactor the code to use await instead?

serializer.py - In the deserialize function, I think that the factory might be a coroutine function. Do you think I need to handle this case by adding code to support asynchronous factories?

easyasme commented 1 month ago

Concept

Modifications Updated Historian, PersistentHistory, workflowmanager, and init.py to pass and utilize MasterSerializer

init.py:

manager.py:

persistence.py:

Questions