GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - networktocode/diffsync: A utility library for comparing and synchronizing different datasets.

BranchesTags
Open more actions menu

Latest commit

 

History

503 Commits
503 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
changes
changes
 
 
diffsync
diffsync
 
 
docs
docs
 
 
examples
examples
 
 
tests
tests
 
 
.cookiecutter.json
.cookiecutter.json
 
 
.dockerignore
.dockerignore
 
 
.gitignore
.gitignore
 
 
.readthedocs.yml
.readthedocs.yml
 
 
.yamllint.yml
.yamllint.yml
 
 
Dockerfile
Dockerfile
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
example.invoke.yml
example.invoke.yml
 
 
mkdocs.yml
mkdocs.yml
 
 
poetry.lock
poetry.lock
 
 
pyproject.toml
pyproject.toml
 
 
renovate.json
renovate.json
 
 
tasks.py
tasks.py
 
 
towncrier_template.j2
towncrier_template.j2
 
 

Repository files navigation

DiffSync

DiffSync is a utility library that can be used to compare and synchronize different datasets.

For example, it can be used to compare a list of devices from 2 inventory systems and, if required, synchronize them in either direction.

Primary Use Cases

DiffSync is at its most useful when you have multiple sources or sets of data to compare and/or synchronize, and especially if any of the following are true:

  • If you need to repeatedly compare or synchronize the data sets as one or both change over time.
  • If you need to account for not only the creation of new records, but also changes to and deletion of existing records as well.
  • If various types of data in your data set naturally form a tree-like or parent-child relationship with other data.
  • If the different data sets have some attributes in common and other attributes that are exclusive to one or the other.

Overview of DiffSync

DiffSync acts as an intermediate translation layer between all of the data sets you are diffing and/or syncing. In practical terms, this means that to use DiffSync, you will define a set of data models as well as the “adapters” needed to translate between each base data source and the data model. In Python terms, the adapters will be subclasses of the Adapter class, and each data model class will be a subclass of the DiffSyncModel class.

DiffSync Components

Once you have used each adapter to load each data source into a collection of data model records, you can then ask DiffSync to “diff” the two data sets, and it will produce a structured representation of the difference between them. In Python, this is accomplished by calling the diff_to() or diff_from() method on one adapter and passing the other adapter as a parameter.

DiffSync Diff Creation

You can also ask DiffSync to “sync” one data set onto the other, and it will instruct your adapter as to the steps it needs to take to make sure that its data set accurately reflects the other. In Python, this is accomplished by calling the sync_to() or sync_from() method on one adapter and passing the other adapter as a parameter.

DiffSync Sync

Simple Example

A = DiffSyncSystemA()
B = DiffSyncSystemB()

A.load()
B.load()

# Show the difference between both systems, that is, what would change if we applied changes from System B to System A
diff_a_b = A.diff_from(B)
print(diff_a_b.str())

# Update System A to align with the current status of system B
A.sync_from(B)

# Update System B to align with the current status of system A
A.sync_to(B)

You may wish to peruse the diffsync GitHub topic for examples of projects using this library.

Documentation

Full documentation for this library can be found over on the Diffsync Docs website:

  • User Guide - Overview, Using the Library, Getting Started.
  • Administrator Guide - How to Install, Configure, Upgrade, or Uninstall the Library.
  • Developer Guide - Extending the Library, Code Reference, Contribution Guide.
  • Release Notes / Changelog.
  • Frequently Asked Questions.

Installation

Option 1: Install from PyPI

pip install diffsync

Option 2: Install from a GitHub branch, such as main as shown below.

pip install git+https://github.com/networktocode/diffsync.git@main

Contributing

Pull requests are welcomed and automatically built and tested against multiple versions of Python through GitHub Actions.

The project is following Network to Code software development guidelines and is leveraging the following:

  • Ruff, mypy for Python linting, formatting and type hint checking.
  • pytest, coverage, and unittest for unit tests.

You can ensure your contribution adheres to these checks by running invoke tests from the CLI. The command invoke build builds a docker container with all the necessary dependencies (including the redis backend) locally to facilitate the execution of these tests.

Contributing to the Documentation

You can find all the Markdown source for the App documentation under the docs folder in this repository. For simple edits, a Markdown capable editor is sufficient: clone the repository and edit away.

If you need to view the fully-generated documentation site, you can build it with MkDocs. A container hosting the documentation can be started using the invoke commands (details in the Development Environment Guide) on http://localhost:8001. Using this container, as your changes to the documentation are saved, they will be automatically rebuilt and any pages currently being viewed will be reloaded in your browser.

Any PRs with fixes or improvements are very welcome!

Questions

For any questions or comments, please check the FAQ first. Feel free to also swing by the Network to Code Slack (channel #networktocode), sign up here if you don't have an account.

About

A utility library for comparing and synchronizing different datasets.

diffsync.readthedocs.io/

Topics

data-synchronizationdiffsyncetlextract-transform-loadpythonsource-of-truthsynchronization

Resources

Readme
License
Activity
Custom properties

Stars

191 stars

Watchers

31 watching

Forks

31 forks
Report repository

Releases

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.