Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: add dataclasses for data model #3

Closed
wants to merge 9 commits into from

Conversation

tangkong
Copy link
Contributor

@tangkong tangkong commented Feb 27, 2024

Description

  • Adds basic datacalsses for Entry, Parameter, Value, Collection, and Snapshot
  • Adds initial validation tests, and a sample database fixture

Motivation and Context

Continue fleshing out structure of this package's backend

Notes on validation

I've chosen apischema here since it is the beast we know, and has similar functionality to pydantic. apischema performs type validation happens on serialization/deserialization, but not outside of that. If we are to be constructing these dataclasses we'll want to validate them before attempting to save them to a backend (whether serialized or not).

To help with that, the .validate() method has been added. This calls the apischema validation routine. Adding routines can be done with the @validator decorator, quite easily.

In pursuit of lazy loading

This section is also the "Why hint Union[UUID, Entry] everwhere?" section

I expect lazy loading will become a requirement, especially as database size grows. I imagine a world where we have a huge root tree structure, with deep nesting of collections and snapshots. In this case, we wouldn't want to pull the whole database's contents with every app load.

Instead we might first grab the metadata information (name, description, creation time), then fill its children when their information is requested. Exactly how we accomplish this should be fleshed out in the client/backend implementations, but the data-model would have to allow "unfilled" references to Entry objects.

How Has This Been Tested?

Added a few tests, need to flesh them out a bit

Where Has This Been Documented?

This PR, soon pre-release notes

Pre-merge checklist

  • Code works interactively
  • Code follows the style guide
  • Code contains descriptive docstrings, including context and API
  • New/changed functions and methods are covered in the test suite where possible
  • Test suite passes locally
  • Test suite passes on GitHub Actions
  • Ran docs/pre-release-notes.sh and created a pre-release documentation page
  • Pre-release docs include context, functional descriptions, and contributors as appropriate

@tangkong tangkong marked this pull request as draft February 27, 2024 00:11
@tangkong tangkong marked this pull request as ready for review February 27, 2024 20:46
@tangkong tangkong changed the title ENH/WIP: add dataclasses for data model ENH: add dataclasses for data model Feb 27, 2024
@tangkong
Copy link
Contributor Author

The guts of this might be ok, but after some deeper thinking about this, I'm not sure this is the data schema we want to go with. Moving to draft for now while conversations happen elsewhere

@tangkong tangkong marked this pull request as draft February 28, 2024 22:18
@tangkong tangkong mentioned this pull request Mar 1, 2024
8 tasks
@tangkong
Copy link
Contributor Author

tangkong commented Mar 1, 2024

superceded by #4

@tangkong tangkong closed this Mar 1, 2024
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