Changes between Version 4 and Version 5 of Session2


Ignore:
Timestamp:
Oct 1, 2015, 9:02:06 AM (10 years ago)
Author:
Greg Couch
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Session2

    v4 v5  
    55From the user perspective, Chimera2 is an application with a suite of tools. In any given session, there may be some user data (e.g., molecules and volumes) and some active tools (e.g., Reply Log and Command Line). One of the required functionality of Chimera2 is to be able to save the current state of the session, and then resume the session in the same state at the future time. This sounds simple enough, but there are some details that need to be explicitly enumerated, as not everyone will agree what consists "the state of the session".
    66
    7 From the developer side, we can distinguish a couple different types of data. Some data are the same for all sessions; for example, start-up preferences and the list of installed tools. Some data are different for different sessions; for example, the list of _active_ tools and the currently opened data files. Let's call the former "initial data" and the latter "session data". Chimera2's "state of the session" consists only of "session data". This means that if the user (a) saves a session, and then (b) changes his start-up preference (e.g., background color) and it was not explicitly overridden in a session (e.g., by changing the background color), then (c) on resumption, the session will use the new background color. Clearly, this may be unexpected for the user. We will need to define what data normally defined by "initial data" that should always be saved as "session data" so that these surprises are minimized. (The answer is not "all of them" because clearly the list of installed tools may change, and additions and deletions cannot be ignored.)
     7From the developer side, we can distinguish a couple different types of data.  Some data are the same for all sessions; for example, start-up preferences and the list of installed tools. Some data are different for different sessions; for example, the list of _active_ tools and the currently opened data files. Let's call the former "initial data" and the latter "session data". Chimera2's "state of the session" consists only of "session data".  This means that if the user (a) saves a session, and then (b) changes his start-up preference (e.g., background color) and it was not explicitly overridden in a session (e.g., by changing the background color), then (c) on resumption, the session will use the new background color. Clearly, this may be unexpected for the user.  We will need to define what data normally defined by "initial data" that should always be saved as "session data" so that these surprises are minimized. (The answer is not "all of them" because clearly the list of installed tools may change, and additions and deletions cannot be ignored.)
    88
    99(Chimera2 data can be categorized as raw data, GUI data, and organizational data. Expound.)
     10
     11=== Data Types ===
     12
     13All session data is simple, //i.e.//, int, float, string, list, dict, //etc.// or an instance of a class provided by a tool.
    1014
    1115== Protocols ==
     
    3135== The Problem ==
    3236
    33 The problem is how to serialize the session state.
    34 Ideally, when restoring a session, all data that is referenced by some other data has already been restored.  Therefore all of dependencies need to be known by the saving code and there can be no circular dependencies.  This avoids two-phase initialization, which is especially important for C++ objects.
     37The problem is how to serialize and deserialize the session state.
     38Ideally, when restoring a session, all data that is referenced by some other data has already been restored.
     39Therefore all of dependencies need to be known by the saving code and there can be no circular dependencies.
     40This avoids two-phase initialization, which is especially important for C++ objects.
    3541
    3642=== Where is Session State? ===
     
    5561* pseudobonds
    5662* surfaces
    57 * generic 3D graphics (e.g. STL)
     63* generic 3D graphics (//e.g.//, STL)
    5864* atom/bond annotations
    5965
     
    8591* so some tools may need to saved before associated model
    8692* does that mean that tools are saved first?
    87 * ordering is complicated
     93
     94How the data is organized in the session does not match the order in which the data needs to be saved.
     95
    8896
    8997=== The Solution ===
     
    9199Circular dependencies are natural.  So use two-phase initialization when deserializing a session.
    92100
    93 Really don't want to use two-phase initialization for C++ objects.  So don't.  As long as the C++ objects are restored all together (i.e., atomic structures and pseudobonds), we can avoid two-phase initialization for them.  If the C++ objects refer to Python objects, that part would need to follow a two-phase protocol.
     101Really don't want to use two-phase initialization for C++ objects.  So don't.  As long as the C++ objects are restored all together (//i.e.//, atomic structures and pseudobonds), we can avoid two-phase initialization for them.  If the C++ objects refer to Python objects, that part would need to follow a two-phase protocol.
    94102
    95 On the Python side, it is possible to provide an API that takes "simple" data and implements all of the individual save and restore steps.
     103On the Python side, it is possible to provide an API that takes simple data and implements all of the individual save and restore steps.
     104
     105=== Tool Classes ===
     106
     107* All classes exported by tools need to have a 'tool_info' attribute, a !ToolInfo instance
     108* !ToolInfo needs the State version in addition to the tool version
     109* When registering a tool's commands, it needs the !ToolInfo instance, just like starting a tool's GUI to be able set the the 'tool_info' attribute if there is no GUI
     110* The tool's module needs a 'get_class' function to return the class associated with a name.
     111* Tool classes might have an alternate initializer if attributes are not simple