<jupyter_start><jupyter_text>Diagraming in PythonThis notebook is intended to show how you can easily create and manipulate diagrams directly in Python code. It uses the [Diagrams](https://diagrams.mingrammer.com/) Python package.<jupyter_code># First things first, install some dependencies

import sys
!conda install --yes --prefix {sys.prefix} diagrams<jupyter_output><empty_output><jupyter_text>Import all of the node types from DiagramsWe need to import the specific node types we plan on using<jupyter_code>from diagrams import Cluster, Diagram
from diagrams.aws.compute import ECS
from diagrams.aws.compute import EKS
from diagrams.aws.storage import S3
from diagrams.aws.integration import SQS<jupyter_output><empty_output><jupyter_text>Next import `display` so we can show our results<jupyter_code>from IPython import display
with Diagram("Event Processing", show=False): 
    EKS("k8s source") \
        >> [SQS("event queue 1"), SQS("event queue2")] \
        >> ECS("ECS consumer") \
        >> S3("events store")

display.Image("./event_processing.png")<jupyter_output><empty_output><jupyter_text>Grouping<jupyter_code>with Diagram("Grouped", show=False):
    with Cluster("Event Workers"):
            workers = [ECS("worker1"), ECS("worker2")]
    EKS("k8s source") >> SQS("event queue") >> workers >> S3("events store")

display.Image("./grouped.png")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11739441660701504, 'fraction_numerical': 0.006442376521116679, 'mean_word_length': 5.5327102803738315, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 29, 'https://': 1, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '348444', 'license': 'MIT', 'n_tokens_mistral': 446, 'n_tokens_neox': 426, 'n_words': 121, 'path': 'sample_diagram/sample_diagram.ipynb', 'repo_name': 'jquintus/jupyter-binders', 'size': '1397'}