<jupyter_start><jupyter_text>Usage Example: PydanticThis notebook shows an example of using erdantic with [Pydantic](https://pydantic-docs.helpmanual.io/) models.Let's take a look at the models from the `erdantic.examples.pydantic` module. Here's their source code for clariy.<jupyter_code>import erdantic.examples.pydantic
??erdantic.examples.pydantic<jupyter_output><empty_output><jupyter_text>Using the CLIThe fastest way to rendering a diagram is to use the command-line interface. Below we use IPython's `!` to run a command in the system shell. We pass the full dotted path to the root class of our composition hierarchy, along with an output file path. erdantic will walk the composition graph to find all child classes.<jupyter_code>!erdantic erdantic.examples.pydantic.Party -o diagram.png<jupyter_output>Rendered diagram to diagram.png<jupyter_text>The format rendered is inferred from the file extension.  Using the Python libraryYou can also use the erdantic Python library, which lets you inspect the diagram object. The diagram object even automatically renders in Jupyter notebooks as demonstrated below.<jupyter_code>import erdantic as erd
from erdantic.examples.pydantic import Party


diagram = erd.create(Party)
diagram
diagram.models
diagram.edges<jupyter_output><empty_output><jupyter_text>You can use the `draw` method to render the diagram to disk.<jupyter_code>diagram.draw("pydantic.svg")

# Equivalently, use erd.draw directly from Party
# erd.draw(Party, out="pydantic.svg")<jupyter_output><empty_output><jupyter_text>erdantic uses [Graphviz](https://graphviz.org/), a venerable open-source C library, to create the diagram. Graphviz uses the [DOT language](https://graphviz.org/doc/info/lang.html) for describing graphs. You use the `to_dot` method to get the DOT representation as a string.<jupyter_code>print(diagram.to_dot())

# Equivalently, use erd.to_dot directly from Party
assert diagram.to_dot() == erd.to_dot(Party)<jupyter_output>digraph "Entity Relationship Diagram" {
	graph [fontcolor=gray66,
		fontsize=9,
		label="Created by erdantic v0.2.0 <https://github.com/drivendataorg/erdantic>",
		nodesep=0.5,
		rankdir=LR,
		ranksep=1.5
	];
	node [fontsize=14,
		label="\N",
		shape=plain
	];
	"erdantic.examples.pydantic.Adventurer"	[label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>Adventurer</b></td></tr><tr><td>name</td><td port="name">str</td></tr><tr><td>profession</td><td port="profession">str</td></tr><tr><td>level</td><td port="level">int</td></tr><tr><td>alignment</td><td port="alignment">Alignment(str, Enum)</td></tr></table>>,
		tooltip="erdantic.examples.pydantic.Adventurer&#xA;&#xA;A person often late for dinner but with a tale or two to tell.&#xA;&#xA;Attributes:&#\
xA;    name (str): Name of this adventurer&#xA;    profession (str): Profession of this adventurer&#xA;    level (int): Level of \
this adventurer&#xA;    alignment (Alignment): Alignment of this adve[...]<jupyter_text>Terminal ModelsIf you have an enormous composition graph and want to chop it up, you can make that work by specifying models to be terminal nodes.For the CLI, use the `-t` option to specify a model to be a terminus. To specify more than one, used repeated `-t` options. So, for example, if you want one diagram rooted by `Party` that terminates at `Quest`, and another diagram that is rooted by `Quest`, you can use the following two shell commands.```basherdantic erdantic.examples.pydantic.Party \     -t erdantic erdantic.examples.pydantic.Quest \    -o party.pngerdantic erdantic.examples.pydantic.Quest -o quest.png``` When using the Python library, pass your terminal node in a list to the `termini` keyword argument. Below is the Python code for creating diagrams equivalent to the above shell commands.<jupyter_code>from erdantic.examples.pydantic import Quest


erd.create(Party, termini=[Quest])
erd.create(Quest)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11215427556457752, 'fraction_numerical': 0.0040598832783557475, 'mean_word_length': 5.77319587628866, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 57, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '292782', 'license': 'MIT', 'n_tokens_mistral': 1270, 'n_tokens_neox': 1211, 'n_words': 398, 'path': 'docs/docs/examples/pydantic.ipynb', 'repo_name': 'adsharma/erdantic', 'size': '3941'}