-
Notifications
You must be signed in to change notification settings - Fork 5
Transition value JSON from old to new flat format #539
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
Draft
suvayu
wants to merge
115
commits into
master
Choose a base branch
from
WIP-data-transition
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
suvayu
commented
May 26, 2025
Contributor
Author
suvayu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add some notes/questions as review comments.
spinedb_api/alembic/versions/a973ab537da2_reencode_parameter_values.py
Outdated
Show resolved
Hide resolved
spinedb_api/alembic/versions/a973ab537da2_reencode_parameter_values.py
Outdated
Show resolved
Hide resolved
TimePattern was implemented as annotated type for schema generation, however this is not distinguishable at runtime, so add an alternate dataclass implementation.
make columns instead of records from old format parameter_value
OleMussmann
reviewed
Jun 2, 2025
- update only rows that need changes - batch row updates - convert types to `table` where necessary - add `transition_data` function override for debugging
Remove unnecessary nullable types, and unused union type (ValueTypes)
Do not use pandas as intermediate step, instead transform ourselves from record based to column based - easier for type inspection. TODO: factor out into specific for data transition and generally useful to inserting into spinedb from outside sources when using spinedb_api as a library.
soininen
reviewed
Sep 29, 2025
|
|
||
|
|
||
| # types | ||
| class TimePeriod(str): |
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this class be replaced by typing.NewType?
TimePeriod = NewType("TimePeriod", str)- simplify with early return - document implementation detail - improve error message
- add pyarrow "duration" type - add pyarrow types to type_map - function to convert pyarrow arrays to model arrays (requirement to be able to serialise pyarrow for the DB)
- separate schema validation (aka pydatic models) & additional conventions like, metadata, restrictions related to value/index columns into models.py & parameter_value.py respectively - improve error message when raising SpineDBAPIError - remove unused functions after refactor
previous workaround was breaking any_array
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Migrate old JSON
parameter_values into the new schema that is more like a flat table (fortime_series,array, andmap) and singularpyarrowcompatible values fordate_time,duration, andtime_pattern.Re spine-tools/Spine-Toolbox#2506
Checklist before merging
Authors
Since GH doesn't support setting multiple people as author in a PR, documenting it here
@OleMussmann, @suvayu