Skip to content

Versioning CLI and Python API - #241

Open
sayefsakin wants to merge 159 commits into
mainfrom
versioning
Open

Versioning CLI and Python API#241
sayefsakin wants to merge 159 commits into
mainfrom
versioning

Conversation

@sayefsakin

@sayefsakin sayefsakin commented Apr 29, 2026

Copy link
Copy Markdown
Collaborator

Adds Versioning with DSI.

  • A command line interface dsi-vcs (rsync-based file version control system) module located in dsi/utils/version_control/.

  • A python API integrated with DSI

  • CLI Commands - Full reference for all 7 commands:

    • init: Initialize a versioning repository in a root folder.
    • add: Add file(s) to the staging area for the next commit.
    • remove: Remove file(s) from the staging area without touching the actual files.
    • delete: Delete file(s) from the staging area for the next commit.
    • commit: Commit a new version with the staged file(s) and an optional message describing the version.
    • branch: Create a new branch with an optional starting point (commit hash).
    • merge: Merge a branch into the current branch with an optional target commit hash.
    • list-branch: List all branches in the versioning repository.
    • switch: Switch to a different branch in the versioning repository.
    • log: List most recent versions of the current branch.
    • diff: Show differences between two versions. If no version is provided, show difference with the latest.
    • restore: Restore a version with commit hash.
    • clone: Clone a DSI-VCS repository.
  • Python API: Complete Version class reference with usage examples

  • Helper Functions: Metadata collection utilities from vcs_metadata_helper.py

  • Database Functions and Schema: SQLite database operations and schema in vcs_db.py

  • Repository Log: Tracks every version operations including contents in staging area.

  • Merkle Tree: Represents the entire directory for a individual version.

  • File Chunking: Default chunking method used FastCDC. File format specific chunking for the following file extensions npy, csv, db, sqlite, sqlitle3, json, xml, and xlsx.

sayefsakin and others added 13 commits April 15, 2026 12:09
The rel_path branch results in only including staged files in the
snapshot.  Complete snapshots of the remote folder are needed so
unchanged files are not omitted in a snapshot.
Previous metadata tracking was only for files.  This tracks
paths (both files and directories) so we can preserve permissions for
directory trees.
This moves the dsi_vcs into dsi as a package under utils so it will be
installed and available.  This also begins tests for the utility.
@sayefsakin
sayefsakin requested a review from jpulidojr April 29, 2026 18:02
Comment thread dsi/utils/version_control/README.md Outdated
Comment thread dsi/utils/version_control/README.md Outdated
Comment thread dsi/utils/version_control/README.md Outdated
Comment thread dsi/dsi.py Outdated
Comment thread dsi/utils/version_control/README.md Outdated
@jpulidojr jpulidojr linked an issue May 14, 2026 that may be closed by this pull request
sayefsakin and others added 6 commits May 21, 2026 10:45
The rel_path branch results in only including staged files in the
snapshot.  Complete snapshots of the remote folder are needed so
unchanged files are not omitted in a snapshot.
@jpulidojr jpulidojr self-assigned this Aug 10, 2026
@jpulidojr jpulidojr added the enhancement New feature or request label Aug 10, 2026
Comment thread dsi/utils/version_control/repolog/chunking.py Outdated
Comment thread dsi/utils/version_control/repolog/chunking.py
Comment thread dsi/utils/version_control/dsi_vcs.py Outdated
Comment thread dsi/utils/version_control/dsi_vcs.py
Comment thread dsi/utils/version_control/dsi_vcs.py
Comment thread dsi/utils/version_control/dsi_vcs.py Outdated
Comment thread dsi/utils/version_control/dsi_vcs.py
Comment thread dsi/utils/version_control/dsi_vcs.py Outdated
txn_id = f"staging-{datetime.datetime.now(datetime.timezone.utc).strftime('%Y%m%d%H%M%S%f')}"

for raw in paths:
rel_path = raw

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this path be relative like it is in add,delete, commit.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably do validity checks on the path like you do in cmd_add.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added validity checks in delete and remove. Every path is considered relative to the root directory. Probably in future, we can add feature that user can add from any subdirectory without specifying the full relative path from root.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you still may want the same path normalization from cmd_add in cmd_delete (e.g., the os.path.relpath) so the staging keys are generated for both. cmd_add also seems to handle absolute paths.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the path normalization. Also added checks to avoid adding outside files through ../../filename from root folder. Also, added recursive file remove and delete.

Comment thread dsi/utils/version_control/dsi_vcs.py Outdated
Comment thread dsi/dsi.py Outdated
Comment thread dsi/dsi.py Outdated
Comment thread dsi/utils/version_control/dsi_vcs.py Outdated
Comment thread dsi/utils/version_control/dsi_vcs.py Outdated
_set_acl_darwin(path, acl_string)
elif sys.platform == "linux":
_set_acl_linux(path, acl_string)
print(f"Unsupported platform for ACL write: {sys.platform}")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be in an else branch?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Also, I'll add windows stuffs later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add native DSI Versioning tracking support

4 participants