A minimal dataset versioning system for text data with a focus on reproducibility.
Project description
Marco Dataset Versioning System
A minimal dataset versioning system for text data with a strong focus on reproducibility and transparency. Treat your text datasets like code โ immutable, versioned, reproducible, and explainable.
Marco acts as a lightweight Python library, meaning you can initialize it in any machine learning project folder to safely version and preprocess your datasets without altering your original files.
๐ Installation (Linux / macOS)
On modern Linux environments (Arch Linux, Ubuntu 23.04+), Python packages must be installed inside a Virtual Environment (PEP 668) to prevent conflicts with system packages.
Follow these steps to safely install Marco into your ML project:
-
Navigate to your ML project folder (e.g. your bag-of-words project):
cd ~/projects/my-bag-of-words-model
-
Create and activate a Python Virtual Environment:
# Create a virtual environment named 'venv' python3 -m venv venv # Activate it (required every time you open a new terminal in this folder) source venv/bin/activate
You should now see
(venv)at the start of your terminal prompt. -
Install Marco:
pip install marco-dvcs
๐ ๏ธ Usage Guide
Once marco is installed in your virtual environment, you have access to the full CLI.
1. Initialize a Repository
Initialize Marco tracking in your current directory. This creates a .marco/ data versioning environment specific to that project.
marco init
This generates a single Root Node linking all future lineage chains, creates the registry files, and provisions a raw/ directory to store your raw data.
2. Create an Immutable Version
Upload a text/CSV/TSV dataset to create an immutable version. Marco computes a cryptographically secure SHA-256 hash from the raw data combined with the preprocessing configuration. It groups dataset versions into Lineage Chains based on the hash of the raw source data, auto-linking parents and children up to the Root Node.
Interactive Mode โ if you don't supply a config file, Marco guides you through building the preprocessing pipeline (lowercasing, tokenization, stopword removal, deduplication):
marco upload my_dataset.csv -t v1-raw
The interactive prompt asks for each step directly โ for example, tokenization skips the Y/n gate and asks for the method name upfront (press Enter to skip):
1. Clean newlines? (Y/n):
2. Convert to lowercase? (Y/n):
3. Tokenization method ['whitespace', 'word', 'char'] (or press Enter to skip): whitespace
4. Remove Stopwords? (Y/n):
5. Filter by length? (Y/n):
6. Deduplicate? (Y/n):
Config Mode โ supply a JSON config directly:
marco upload my_dataset.csv -c my_config.json -t v1-processed
Note: During upload, Marco automatically generates a
raw_stats.jsonartifact inside the version directory. This file captures pristine, pre-pipeline dataset statistics โ including vocabulary size, document length distributions (avg, median, std, min, max), and label distributions.
Recommended workflow โ upload your data, then train and auto-attach results in one step:
marco upload data.txt -t v1-raw
python Naive_base_Model.py v1-raw
3. Train & Attach Results โ Simplified Workflow
Pass a Marco version tag directly to your training script โ no manual restore or attach-results steps needed:
# Upload your dataset
marco upload data.txt -t v1-raw
# Train and auto-attach results in one command
python Naive_base_Model.py v1-raw
What happens under the hood when you run python Naive_base_Model.py v1-raw:
- Loads โ resolves
v1-rawand readspreprocessed.tsvdirectly from.marco/versions/ - Trains โ runs the Naive Bayes model on the preprocessed data
- Attaches โ saves
training_results.txtback into the version automatically
This requires
Naive_base_Model.pyto importmarcoand callmarco.get_data()/marco.save_results(). See the Python SDK section below.
Legacy approach (manual, still supported):
marco restore v1-raw -o ./my_training_data.tsv
python Naive_base_Model.py ./my_training_data.tsv
marco attach-results v1-raw training_results.txt
(Note: You can also use the shorter marco attach alias for attach-results)
Python SDK โ Integrate Marco into Any Script
To make any training script Marco-aware, import marco and use two functions:
import marco
# Resolve version tag โ path to preprocessed.tsv (auto-detects .marco folder)
data_path = marco.get_data("v1-raw") # returns a pathlib.Path
# After training, store the results file back into the version
marco.save_results("v1-raw", "training_results.txt")
Minimal example โ adapting any script to accept a version tag:
import sys, marco, pandas as pd
version_tag = sys.argv[1] # e.g. "v1-raw"
df = pd.read_csv(marco.get_data(version_tag), sep="\t")
# ... your training code ...
marco.save_results(version_tag, "results.txt")
print("Done โ results attached to version", version_tag)
Both functions auto-walk up your directory tree to find the .marco/ folder, so they work from any subdirectory of your project.
4. List Versions
View all versions you've created, along with their tags, chains, and timestamps.
marco list
5. View Lineage Tree
View a visual ASCII-art representation of your project's history, tracing all versions back up through their lineage chains directly to the project's central Root Node.
marco lineage
6. Restore / Checkout Data
Extract the processed dataset from Marco's storage back into your active workspace for model training.
marco restore v1-processed -o ./training_data.tsv
7. Export / Import Versions
Easily share dataset versions with teammates by packing them into .tar.gz archives.
# Export version 'v1-raw' to the 'exports' folder
marco export v1-raw ./exports/
# Import an archive received from a teammate
marco import ./exports/marco_version_e5e0b767.tar.gz
8. Delete Versions
Delete a dataset version to recover disk space. Marco intelligently updates the lineage (parents history) of any descendant versions so that your Git-style history tree remains intact.
marco delete v1-raw
# or by hash
marco rm e5e0b767
9. Diff Versions โ Unified ---/+++ Format
marco diff instantly prints a human-readable summary of how key metrics changed (e.g. "15% increase in tokens") followed by a line-by-line unified diff directly to the terminal โ no files written, no clutter.
Diff the raw source data (default):
marco diff v1.0 v2.0
Diff the post-pipeline preprocessed output:
marco diff v1.0 v2.0 --target preprocessed
Diff the DAG preprocessing configuration:
marco diff v1.0 v2.0 --target config
Control how many context lines surround each hunk (default: 3):
marco diff v1.0 v2.0 --context 10
Save a full Markdown metrics report to a folder (opt-in):
marco diff v1.0 v2.0 --save ./reports
Example terminal output:
๐ Summary: v1.0 โ v2.0
โบ N Documents: 2.00% increase (50 โ 51)
โบ N Tokens: 15.30% increase (1000 โ 1153)
โบ Vocab Size: 5.10% increase (300 โ 315)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
--- v1.0 (abc12345)/raw.txt
+++ v2.0 (def67890)/raw.txt
@@ -1,5 +1,6 @@
positive Great product, love it!
-negative Terrible experience.
+negative Poor experience, not recommended.
+negative Worst purchase I ever made.
positive Highly recommend to everyone.
neutral It was okay, nothing special.
10. KL Divergence & Token Analytics
Marco goes beyond simple vocabulary size tracking. It uses KL divergence (Kullback-Leibler) to measure exactly how token probability distributions shift between two dataset versions โ telling you whether common words disappeared or rare domain terms suddenly dominated.
marco token-analytics v1-raw v2-processed
11. Evaluate Dataset Health
Get a comprehensive evaluation report covering dataset statistics, distributions, and potential issues for a specific dataset version.
marco evaluate v1-processed
12. Track Model Drift
Detect performance degradation across dataset versions instantly using dynamic text mining. Marco automatically scans your attached unstructured results.txt or training_results.json files for baseline performance metrics (using Regex to extract Accuracy, Precision, Recall, and F1 from arbitrary terminal logs). It then dynamically spins up an internal, lightweight Scikit-Learn MultinomialNB pipeline to evaluate the new data in-memory without needing a serialized .pkl file.
marco drift v1-trained v2-processed
Example terminal output (Metrics not found in the baseline text file are gracefully omitted from comparison!):
MODEL DRIFT ANALYSIS
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Trained on: V_OLD (fe4403)
Evaluated on: V_NEW (a3f9c1)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Metric V_OLD (baseline) V_NEW (new) Drop Severity
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Accuracy 0.700 0.612 -12.6% CRITICAL
F1 0.547 0.485 -11.3% CRITICAL
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Overall: RETRAIN
"Significant dataset shift detected. Model cannot explain
new data variance. Retraining recommended."
13. Launch the Web UI
Spin up a local interactive web dashboard to visually explore all your tracked versions, their DAG pipelines, raw/preprocessed data, training results, and health statistics โ all in one place.
marco generate-web
Opens http://localhost:7654 automatically. The UI provides three views toggled from the top-right corner:
| View | What You See |
|---|---|
| DAG | Interactive pipeline graph โ click any node to inspect step metrics and config params |
| Code | Pipeline steps rendered as readable code blocks with token counts |
| Data | Browse Raw Input, Processed Output, Training Results, and Config per version (with pagination) |
The left sidebar shows your repository grouped by Lineage Chain with v1-raw, v2-updated ref labels pulled directly from refs.json. The bottom bar shows live document/token/vocab counts with +/- deltas when comparing two versions.
Press Ctrl+C to stop the server.
๐ฌ Reproducibility Proof
Marco guarantees that a dataset version is not just stored โ it is provably reproducible. The marco/reproducibility_proof/ module lets you mathematically verify that re-running the exact same pipeline on the same raw data produces a byte-identical result.
1. Verify a Single Version
Re-runs the full preprocessing pipeline from scratch and compares the freshly computed output hash against the stored hash in the manifest. Before computing the pipeline, it performs a zero-trust file integrity check to ensure the stored dataset itself has not been tampered with.
marco verify v1-raw
# or with a full hash
marco verify fe44032c
Example output:
๐ฌ Verifying version: fe44032c70164a71...
Pipeline Step Verification:
โ
step_1 normalize_newlines
โ
step_2 lowercase
Stored output_hash: ed610672ea28e065...
Recomputed hash: ed610672ea28e065...
โ
VERIFIED โ output hash matches. Version is reproducible.
- On PASS: the manifest is updated with
"verified": true, a timestamp, the current environment snapshot, and per-step hashes. - On FAIL: a
verification_report.jsonis written inside the version folder with a row-level delta showing exactly which rows differ. Exit code is1.
2. Verify All Versions at Once
Audit every version in the repository and get a clean summary table.
marco verify-all
Example output:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Marco Reproducibility Audit โ 3 version(s) found
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ฌ Verifying version: a3f9c1d2... โ
VERIFIED
๐ฌ Verifying version: fe44032c... โ
VERIFIED
๐ฌ Verifying version: 83f77823... โ FAIL
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Summary: 2/3 versions passed.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Returns exit code 1 if any version fails โ making it CI/CD friendly.
How the 7-Layer Reproducibility Engine Works
| # | Guarantee | How It Works |
|---|---|---|
| 1 | Step-by-step hash verification | Hashes the output after every individual DAG step. Pinpoints exactly which step introduced non-determinism (โ
step_1, โ step_2). |
| 2 | Byte-exact canonical enforcer | Before hashing, data is serialized into a strictly defined canonical TSV format: Unix line endings only, fixed column order (label, text, n_tokens), UTF-8 encoding. Prevents false FAIL results from OS differences (Windows CRLF vs Linux LF). |
| 3 | Row-level delta on FAIL | When a hash mismatch occurs, computes exactly which rows were added or removed between the stored output and the fresh recompute, saved in verification_report.json. |
| 4 | Permanent audit trail | Every verification run (PASS or FAIL) is appended to .marco/verification_log.jsonl with a timestamp, result, and full environment snapshot โ a tamper-evident history. |
| 5 | Environment fingerprinting | Stores Python version, NumPy/Pandas versions, and platform info in the manifest at verification time. Warns on re-verification if the environment changed: "Python 3.10 โ 3.14 (may explain hash mismatch)". |
| 6 | Stochastic operation detector | Scans the pipeline DAG config for non-deterministic functions (e.g. shuffle, random_sample) that lack a seed parameter. Warns before verifying so expectations are set correctly. |
| 7 | Manifest integrity update | On PASS: sets "verified": true in manifest.json and persists per-step hashes. On FAIL: sets "verified": false and keeps verification_report.json alongside the version data. |
Verification Report (verification_report.json)
When a version fails, Marco writes a full diagnostic file at .marco/versions/<version_id>/verification_report.json:
{
"version_id": "fe44032c...",
"verified_at": "2026-03-18T14:01:00Z",
"result": "FAIL",
"stored_hash": "ed610672...",
"computed_hash": "a3f9c1d2...",
"step_hashes": {
"step_1": "aabbcc...",
"step_2": "ddeeff..."
},
"stochastic_warnings": [],
"environment_warnings": ["python_version changed: '3.10' โ '3.14'"],
"row_delta": {
"count_stored": 1000,
"count_computed": 998,
"removed": [["pos", "hello world"], ["neg", "bad product"]],
"added": []
}
}
๐ง Architecture Overview
Marco decouples logic from the file system. All core engine operations live inside marco/core/:
locker.pyโ File-based concurrency control using.lockfiles.repository.pyโ CRUD operations for dataset versions andrefs.jsontagging. Enforces file immutability by setting read-only permissions (0o444) on all version files immediately after creation.preprocessor.pyโ A robust Directed Acyclic Graph (DAG) preprocessing engine with deterministic topological execution.comparator.pyโ Version comparison via Markdown metric reports (compare_versions) and classic---/+++unified diffs (diff_versions_text) using Python's stdlibdifflib.
Reproducibility Proof Engine (marco/reproducibility_proof/)
canonicalizer.pyโ Enforces byte-exact canonical serialization (Unix line endings, fixed column order). Also detects stochastic/non-deterministic pipeline operations.audit_log.pyโ Appends every verification run (PASS or FAIL) to.marco/verification_log.jsonlwith a full environment snapshot.verify.pyโ End-to-end reproducibility verification with step-by-step hashing, row-level delta reports, environment fingerprinting, and averify_all()batch audit command.
Have fun building safer machine learning pipelines!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file marco_dvcs-0.1.77.tar.gz.
File metadata
- Download URL: marco_dvcs-0.1.77.tar.gz
- Upload date:
- Size: 322.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4cb1aa9becf990c73381e571f30c57ca2be62f4dd0293735bf3622fab01aed09
|
|
| MD5 |
9f928d268747070552dc6f5849aa5aa6
|
|
| BLAKE2b-256 |
d5f1ffff33287ae835e5f7bc1e7f077a0f88fa553cf9f1ede91f9a8335444e3e
|
File details
Details for the file marco_dvcs-0.1.77-py3-none-any.whl.
File metadata
- Download URL: marco_dvcs-0.1.77-py3-none-any.whl
- Upload date:
- Size: 325.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3ed4b6ae3fe68c06c1ab6bda5f01927a6f2b78a5747fee0e60177b12f8c6e4b
|
|
| MD5 |
ffdaeb7f53d7a5e59aeac95666356afe
|
|
| BLAKE2b-256 |
2a380b3ee57f6154df6853e4005c8f344c24116ae35f09e03c2ab7371b962523
|