Skip to content

WiP: Save state in LO Event#209

Merged
bradley-erickson merged 19 commits intomasterfrom
pbrost/coglabs_deployment
Feb 25, 2025
Merged

WiP: Save state in LO Event#209
bradley-erickson merged 19 commits intomasterfrom
pbrost/coglabs_deployment

Conversation

@bradley-erickson
Copy link
Collaborator

This pull request implements the ability to save and load state within LO Event. This includes both clientside and server-side storage.

Branch: Pbrost/coglabs deployment

user_id, source, activity,
event['blob']
)
elif event['event'] == 'fetch_blob':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bradley-erickson I am wondering how this will play with client-side code. Ideally, this would be spent back before we're done with metadata / init / headers / auth (before the events start streaming).

We should chat in the morning about whether the client should request this when opening the websocket or whether this should be automatically sent.

'''
key = _make_key(user_id, source, activity)
kvs = learning_observer.kvs.KVS()
return await kvs[key]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the key is missing from the kvs? Should probably return that there was nothing (empty object or None).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine for now. null and not None.

$ json.dumps(None)
'null'

In the long term, we should support having a default value. In the long term, I would envision this being part of a module rather than the core. But we've got a long way before we're ready for that.

(Also, note that's different from json.dumps("null") which is '"null"')

@bradley-erickson
Copy link
Collaborator Author

bradley-erickson commented Jan 14, 2025

To get the code to work properly, you'll need to include both the redux and websocket logger as well as a locked field specifying the activity.

lo_event.init(
  "org.ets.sba",
  "0.0.1",
  [consoleLogger(), reduxLogger.reduxLogger([], {}), websocketLogger.websocketLogger('ws://localhost:8888/wsapi/in/')],
  // ...
);
lo_event.setFieldSet([{ activity: 'toy-sba' }]);
lo_event.go();

lo_event.logEvent('fetch_blob', {});

@bradley-erickson bradley-erickson merged commit 783c904 into master Feb 25, 2025
1 check failed
bradley-erickson added a commit to ArgLab/ArgLab_writing_observer that referenced this pull request Oct 7, 2025
* code compiling for deployment of toy-sba

* state sync implemented, state load backed out

* persist redux store in local storage

* removed unused npm packages

* added draft of server side blob storage

* blob loading functionality passed to Brad

* updated lo event to allow for fetching/retrieving state

* change to handleLoadState to return IS_LOADED in state

* added lo_toy_sba module

* change to how state is returned in redux logger

* changing reset logic

* handle save_setting event in redux logger

* code cleanup

* toy sba module cleanup

* small styling changes

* debug logic for save state added

* save_blob fix

* cleaned up console statements and linted reduxlogger

---------

Co-authored-by: Paul Brost <pbrost@ets.org>
DrLynch pushed a commit to ArgLab/ArgLab_writing_observer that referenced this pull request Oct 10, 2025
* code compiling for deployment of toy-sba

* state sync implemented, state load backed out

* persist redux store in local storage

* removed unused npm packages

* added draft of server side blob storage

* blob loading functionality passed to Brad

* updated lo event to allow for fetching/retrieving state

* change to handleLoadState to return IS_LOADED in state

* added lo_toy_sba module

* change to how state is returned in redux logger

* changing reset logic

* handle save_setting event in redux logger

* code cleanup

* toy sba module cleanup

* small styling changes

* debug logic for save state added

* save_blob fix

* cleaned up console statements and linted reduxlogger

---------

Co-authored-by: Paul Brost <pbrost@ets.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants