Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c9c0ecf
Added routes for main version control actions
be-smith Sep 23, 2025
ec6cfac
Added a robust get version number helper to make sure users can't try…
be-smith Oct 9, 2025
37bcd26
Changed to refocde rather than item id
be-smith Oct 10, 2025
9b015a2
Add deepdiff dependency for nested structure comparison
be-smith Oct 10, 2025
c87a441
Improve compare_versions to handle nested structures with DeepDiff
be-smith Oct 10, 2025
55d7c8c
Add data validation and field protection to restore_version
be-smith Oct 10, 2025
0098585
Add action field for version history audit trail
be-smith Oct 10, 2025
e76af1f
Fix transaction safety in save_item by reversing operation order
be-smith Oct 10, 2025
ed3584c
Add version field to HasRevisionControl trait and fix auto-increment
be-smith Oct 12, 2025
caf2b8f
Add comprehensive tests for version control endpoints
be-smith Oct 12, 2025
05b6771
Fix version control restore audit trail
be-smith Oct 13, 2025
0a33558
Add version control UI to webapp
be-smith Oct 13, 2025
9f4821c
Add comprehensive action field tests for version control
be-smith Oct 13, 2025
208402d
update uv lock
be-smith Oct 13, 2025
641fc69
Ensures json is serializable for difference displaying
be-smith Oct 15, 2025
b0a155e
Renamed old data to data to better reflect that the current snapshot …
be-smith Nov 4, 2025
c1fc203
Ensured an initial version is created upon sample creation.
be-smith Nov 4, 2025
cf7ea1b
Hiding UI for now
be-smith Nov 5, 2025
9f460bb
Added indexes to mongodb for efficient lookup
be-smith Nov 5, 2025
8714806
Changed how user info is stored, now has the object which is a snapsh…
be-smith Nov 5, 2025
5337003
Adds tests to ensure we are populating a user_id field in the version…
be-smith Nov 5, 2025
c26a75e
Fixed software versioning
be-smith Nov 5, 2025
3856bb4
Added comprehensive sample lifecycle test for creating, modifying and…
be-smith Nov 5, 2025
0929235
Ensured correct software_version is added to version data
be-smith Nov 5, 2025
4751bc2
Merge branch 'main' into bes/revision_history_clean_history
be-smith Nov 5, 2025
888445a
fixing pre commit
be-smith Nov 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pydatalab/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ dependencies = [
"pint ~= 0.24",
"pandas[excel] ~= 2.2",
"pymongo ~= 4.7",
"deepdiff ~= 8.1",
]

[project.urls]
Expand Down
10 changes: 10 additions & 0 deletions pydatalab/schemas/cell.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
"title": "Revisions",
"type": "object"
},
"version": {
"title": "Version",
"default": 1,
"type": "integer"
},
"creator_ids": {
"title": "Creator Ids",
"default": [],
Expand Down Expand Up @@ -525,6 +530,11 @@
"title": "Revisions",
"type": "object"
},
"version": {
"title": "Version",
"default": 1,
"type": "integer"
},
"creator_ids": {
"title": "Creator Ids",
"default": [],
Expand Down
10 changes: 10 additions & 0 deletions pydatalab/schemas/equipment.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
"title": "Revisions",
"type": "object"
},
"version": {
"title": "Version",
"default": 1,
"type": "integer"
},
"creator_ids": {
"title": "Creator Ids",
"default": [],
Expand Down Expand Up @@ -489,6 +494,11 @@
"title": "Revisions",
"type": "object"
},
"version": {
"title": "Version",
"default": 1,
"type": "integer"
},
"creator_ids": {
"title": "Creator Ids",
"default": [],
Expand Down
10 changes: 10 additions & 0 deletions pydatalab/schemas/sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
"title": "Revisions",
"type": "object"
},
"version": {
"title": "Version",
"default": 1,
"type": "integer"
},
"creator_ids": {
"title": "Creator Ids",
"default": [],
Expand Down Expand Up @@ -578,6 +583,11 @@
"title": "Revisions",
"type": "object"
},
"version": {
"title": "Version",
"default": 1,
"type": "integer"
},
"creator_ids": {
"title": "Creator Ids",
"default": [],
Expand Down
10 changes: 10 additions & 0 deletions pydatalab/schemas/startingmaterial.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
"title": "Revisions",
"type": "object"
},
"version": {
"title": "Version",
"default": 1,
"type": "integer"
},
"creator_ids": {
"title": "Creator Ids",
"default": [],
Expand Down Expand Up @@ -631,6 +636,11 @@
"title": "Revisions",
"type": "object"
},
"version": {
"title": "Version",
"default": 1,
"type": "integer"
},
"creator_ids": {
"title": "Creator Ids",
"default": [],
Expand Down
3 changes: 3 additions & 0 deletions pydatalab/src/pydatalab/models/traits.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class HasRevisionControl(BaseModel):
revisions: dict[int, Any] | None = None
"""An optional mapping from old revision numbers to the model state at that revision."""

version: int = 1
"""The version number used by the version control system for tracking snapshots."""


class HasBlocks(BaseModel):
blocks_obj: dict[str, DataBlockResponse] = Field({})
Expand Down
17 changes: 17 additions & 0 deletions pydatalab/src/pydatalab/mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ def create_default_indices(
- An index over item type,
- A unique index over `item_id` and `refcode`.
- A text index over user names and identities.
- Version control indexes:
- Index on item_versions.refcode for fast version history lookup
- Index on item_versions.user_id for fast user contribution queries
- Compound index on (refcode, version_number) for sorted version history
- Unique index on version_counters.refcode for atomic version numbering

Parameters:
background: If true, indexes will be created as background jobs.
Expand Down Expand Up @@ -208,4 +213,16 @@ def create_user_fts():
db.users.drop_index(user_fts_name)
ret += create_user_fts()

# Version control indexes
ret += db.item_versions.create_index("refcode", name="version refcode", background=background)
ret += db.item_versions.create_index("user_id", name="version user_id", background=background)
ret += db.item_versions.create_index(
[("refcode", pymongo.ASCENDING), ("version_number", pymongo.DESCENDING)],
name="refcode and version number",
background=background,
)
ret += db.version_counters.create_index(
"refcode", unique=True, name="unique refcode counter", background=background
)

return ret
Loading