Skip to content

Add JSON conversion warnings, store save-type metadata and use ns file timestamps (v0.8.2) - #8

Open
kyrylo-gr wants to merge 1 commit into
devfrom
codex/fix-issue-#6
Open

Add JSON conversion warnings, store save-type metadata and use ns file timestamps (v0.8.2)#8
kyrylo-gr wants to merge 1 commit into
devfrom
codex/fix-issue-#6

Conversation

@kyrylo-gr

@kyrylo-gr kyrylo-gr commented Apr 7, 2026

Copy link
Copy Markdown
Owner

Motivation (#6)

  • Improve visibility when lists are coerced to JSON strings during save and allow controlling warning behavior.
  • Record how values were stored (e.g. JSON string, H5 dataset, serialized function) and surface that in the object representation.
  • Increase file-modification precision and robustness by using nanosecond timestamps and file size to detect external changes.

Description

  • Added a JSON-conversion warning helper _warn_json_conversion_if_needed and extended transform_not_dict_on_save to accept json_conversion_mode and key so conversions can warn in modes all, auto, or be muted; recursive calls mute warnings.
  • Extended save_sub_dict and save_dict to accept json_conversion_mode and a storage_type dict to collect metadata about how each key was stored, and changed save_dict to return nanosecond-resolution modification time (int) instead of float mtime.
  • Tracked file st_size and st_mtime_ns in DH5, updated loading/saving logic to use os.stat(...).st_mtime_ns and st_size, and updated pull_available to compare both mtime and size.
  • Stored per-key saved-type metadata in DH5._saved_storage_type and appended saved-type postfixes to the repr via output_dict_structure additional info.
  • Added validation for constructor parameter json_conversion_mode and defaulted it to "auto" in DH5.
  • Minor refactor/formatting in dict_structure.py and ensured warnings/logging import in data_transformation.py.

Testing

  • Ran the unit tests in tests/dh5_class_tests/main_test.py, including newly added test_repr_contains_saved_type_after_save and test_json_conversion_warning_modes, and they passed under the unittest run.
  • Existing API-level tests (save/open/representation) were executed and succeeded.

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.

1 participant