JSONStore: read_json_file enhancements #1001
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
JSONStore
uses theread_json_file
method duringconnect
to aggregate contents of one or more json files into aMemoryStore
. This PR contains several quality of life improvements to make this method more reliable and easier to debug.Changes
connect
fails and it is very difficult to determine the reason. This PR theread_json_file
call in a try/except block and adds logging messages that make it easier to tell which file is causing the problem, and what the error is.read_json_files
useszopen
to access each file in read-write mode. This is unnecessary and can contradict the spirit of theread_only
kwarg. This PR change thezopen
call to read-only.last_updated
field, one will now be added (and set to the current time)monty
dumpfn
, the field will be a completedict
version of adatetime
object, e.g.This PR adds logic to
read_json_files
that will replacelast_updated
with just the contents ofstring
, because that is whatmaggma
expects.