This document describes the structure of the Lineage Definition Format (LDF) Python library.
lineage-data-format/
├── src/ldf/ # Main package source
│ ├── __init__.py # Public API exports
│ ├── converter.py # Core conversion functions
│ └── cli.py # Command-line interface
│
├── examples/ # Usage examples and test data
│ ├── basic_usage.py # Simple API usage example
│ ├── convert_example.py # Real data conversion example
│ ├── mock_50_nodes_linear_edges.json # Test data (50 nodes)
│ └── mock_100_nodes_combined_edges.json # Test data (100 nodes)
│
├── tests/ # Test suite
│ ├── __init__.py
│ └── test_converter.py # Comprehensive converter tests
│
├── pyproject.toml # Package configuration
├── README.md # Main documentation
├── INSTALL.md # Installation guide
├── LICENSE # License file
└── .gitignore # Git ignore rules
Core conversion module containing:
json_to_lineage_format(graph, options)- Convert dict to LDF stringlineage_format_to_json(input_text)- Convert LDF string to dictconvert_json_file_to_lineage(input_path, output_path, compact)- File conversionconvert_lineage_file_to_json(input_path, output_path, indent)- File conversion
Command-line interface providing:
ldf json-to-lineage- Convert JSON file to LDFldf lineage-to-json- Convert LDF file to JSON
Public API exports for library usage.
Run tests with:
pytestRun tests with coverage:
pytest --cov=ldfcd examples
python3 basic_usage.pycd examples
python3 convert_example.pyThis will:
- Convert mock JSON files to LDF format
- Convert LDF back to JSON
- Verify round-trip conversion integrity
-
Setup virtual environment:
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install in development mode:
pip install -e ".[dev]" -
Make changes to code
-
Run tests:
pytest
-
Run examples to verify:
python examples/convert_example.py
Build the package:
python -m buildThis creates distribution files in dist/:
ldf-0.1.0.tar.gz(source distribution)ldf-0.1.0-py3-none-any.whl(wheel distribution)
- Lossless conversion: Full round-trip fidelity between JSON and LDF
- Token optimization: 60-80% reduction in token count vs verbose JSON
- Type preservation: All data types and structures maintained
- Extensible: Supports custom attributes and metadata
- Well-tested: Comprehensive test suite with real data
- CLI included: Easy command-line tools for conversion