Skip to content

widip/nx_yaml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nx_yaml

Fast Representation Graph for PyYAML using NetworkX.

Usage

Text <-> native

import yaml
from nx_yaml import NxSafeDumper, NxSafeLoader

data_in = yaml.load("yaml: great", Loader=NxSafeLoader)
data_out = yaml.dump(data_in, Dumper=NxSafeDumper)
print(data_out)

Text <-> graph

import networkx as nx
import matplotlib.pyplot as plt

data_out = yaml.compose("[nx, also great]", Loader=NxSafeLoader)
nx.draw_spectral(data_out, with_labels=True, node_size=5000)
plt.show()

Design

All users

This library offers four implementations that jointly bypass the pyyaml.nodes library. This is transparent when you use load and dump since the representation graph is an implementation detail. This library will be faster thanks to a better graph implementation.

Graph users

Users of graphs who use the compose and represent will now get NetworkX objects. NX is a fully fledged library compared to the barebones yaml.nodes module.

With nx_yaml NetworkX becomes your native representation graph using YAML. There is no need to convert between the yaml.nodes.Node and nx.DiGraph by hand.

See:

Implementation

RGraph

Four abstraction isolate and replace pyyaml.nodes representation graph implementation:

Milestone 1

  1. Copy and paste from PyYAML
  2. Replace uses of nodes with NetworkX
  3. Publish a drop-in pip replacement

Milestone 2

  1. Compare performance
  2. Compare alignment with spec
  3. Share findings

Development environment

This is work in progress. pypi is updated on demand.

The development environment is self-contained using the pipenv tool.

Testing

  • Just pytest
  • Store graphs in resources/tests