Block connection testing and Docker improvement
Tested different block connection methods to achive orthogonal lines. Added run script and mounted code to the container to allow code changes without rebuilding the image. Implement Docker improvements in main.
This commit is contained in:
parent
bf788ca544
commit
83283c0657
@ -4,7 +4,7 @@ RUN apk add --no-cache \
|
||||
py3-yaml \
|
||||
graphviz
|
||||
|
||||
WORKDIR /code
|
||||
COPY code/ .
|
||||
COPY run.sh /run.sh
|
||||
RUN chmod +x /run.sh
|
||||
|
||||
CMD ["python3", "puudot.py"]
|
||||
CMD ["./run.sh"]
|
||||
|
||||
@ -8,6 +8,8 @@ import uuid
|
||||
# - also see: https://stackoverflow.com/questions/53862417/how-to-set-head-and-tail-position-in-nodes-graphviz
|
||||
# Solve layering of clusters
|
||||
# - https://observablehq.com/@gordonsmith/church
|
||||
# https://candide-guevara.github.io/cs_related/2019/09/10/graphviz-examples.html
|
||||
# https://forum.graphviz.org/t/set-nodes-from-left-to-right-and-other-from-top-to-bottom-on-the-same-rank/1860
|
||||
|
||||
|
||||
|
||||
@ -40,9 +42,21 @@ def make_link_line(link, config):
|
||||
return line + "\n"
|
||||
|
||||
def make_block_line(block, config):
|
||||
line = f"subgraph cluster_{block['id']} {{\n{config["subgraph"]}\nlabel=\"{block['label']}\"\n"
|
||||
for node in block["texts"]:
|
||||
configs = []
|
||||
if block['hidden']:
|
||||
configs.append(config["subgraph"]["hidden"])
|
||||
else:
|
||||
configs.append(config["subgraph"]["block"])
|
||||
|
||||
config_line = "\n".join(configs)
|
||||
|
||||
line = f"subgraph cluster_{block['id']} {{\n{config_line}\nlabel=\"{block['label']}\"\n"
|
||||
for node in block["nodes"]:
|
||||
line += f"{node}\n"
|
||||
#if block['hidden']:
|
||||
#line += "{rank=same\nedge [constraint=false]\n"
|
||||
#line += f"{block['nodes'][0]} -- {block['nodes'][1]}\n"
|
||||
#line += "}"
|
||||
return line + "}\n\n"
|
||||
|
||||
|
||||
@ -76,7 +90,6 @@ class Graph:
|
||||
def __init__(self):
|
||||
self.config = {}
|
||||
|
||||
self.layers = {}
|
||||
self.blocks = []
|
||||
self.nodes = []
|
||||
self.links = []
|
||||
@ -89,12 +102,15 @@ class Graph:
|
||||
dot = config.get("dot", {})
|
||||
if dot != {}:
|
||||
dot["graph"] = dot.get("graph", "")
|
||||
dot["subgraph"] = dot.get("subgraph", "")
|
||||
dot["subgraph"] = dot.get("subgraph", {})
|
||||
dot["subgraph"]["block"] = dot["subgraph"].get("block", "")
|
||||
dot["subgraph"]["hidden"] = dot["subgraph"].get("hidden", "")
|
||||
dot["node"] = dot.get("node", {})
|
||||
dot["node"]["text"] = dot["node"].get("text", "")
|
||||
dot["node"]["hidden"] = dot["node"].get("hidden", "")
|
||||
dot["edge"] = dot.get("edge", {})
|
||||
dot["edge"]["default"] = dot["edge"].get("default", "")
|
||||
dot["edge"]["middle"] = dot["edge"].get("middle", "")
|
||||
dot["edge"]["hidden"] = dot["edge"].get("hidden", "")
|
||||
self.config = dot
|
||||
|
||||
@ -108,10 +124,10 @@ class Graph:
|
||||
new_block = {
|
||||
"id": block_id,
|
||||
"label": block.get("label", ""),
|
||||
"texts": []
|
||||
"nodes": [],
|
||||
"hidden": False
|
||||
}
|
||||
|
||||
#prev_node_id = ""
|
||||
texts_in_block = block.get("texts", [])
|
||||
for i, text in enumerate(texts_in_block):
|
||||
node_id = get_id()
|
||||
@ -120,21 +136,27 @@ class Graph:
|
||||
if i == math.ceil(len(texts_in_block) / 2) - 1:
|
||||
for link in block.get("links", []):
|
||||
if link in linker:
|
||||
"""link_node1 = get_id()
|
||||
link_node2 = get_id()
|
||||
|
||||
self.nodes.append({"id": link_node1, "text": "", "hidden": True})
|
||||
self.nodes.append({"id": link_node2, "text": "", "hidden": True})
|
||||
|
||||
link_block_id = get_id()
|
||||
self.blocks.append({"id": link_block_id, "label": "", "nodes": [link_node1, link_node2], "hidden": True})
|
||||
|
||||
self.links.append({"from": linker[link], "to": link_node1, "head": "", "hidden": False})
|
||||
#self.links.append({"from": link_node1, "to": link_node2, "head": "", "hidden": False})
|
||||
self.links.append({"from": link_node2, "to": node_id, "head": block_id, "hidden": False})"""
|
||||
self.links.append({"from": linker[link], "to": node_id, "head": block_id, "hidden": False})
|
||||
del linker[link]
|
||||
|
||||
self.nodes.append({"id": node_id, "text": text.get("text", ""), "hidden": False})
|
||||
|
||||
# Chain nodes in block
|
||||
#if prev_node_id:
|
||||
# self.links.append({"from": prev_node_id, "to": node_id, "head": "", "hidden": True})
|
||||
|
||||
new_block["texts"].append(node_id)
|
||||
new_block["nodes"].append(node_id)
|
||||
|
||||
for link in text.get("links", []):
|
||||
linker[link] = node_id
|
||||
|
||||
#prev_node_id = node_id
|
||||
|
||||
self.blocks.append(new_block)
|
||||
|
||||
|
||||
15
config.yaml
15
config.yaml
@ -1,12 +1,17 @@
|
||||
dot:
|
||||
graph: |
|
||||
graph [splines=ortho, nodesep=0.2, ranksep="0.5 equally"]
|
||||
graph [splines=true, nodesep=0.25, ranksep="1 equally"]
|
||||
//graph [splines=ortho, nodesep=0.2, ranksep="0.5 equally"]
|
||||
//node [color=white]
|
||||
//edge [headport=n, tailport=s]
|
||||
compound=true
|
||||
center=true
|
||||
subgraph: |
|
||||
labeljust=l
|
||||
subgraph:
|
||||
block: |
|
||||
labeljust=l
|
||||
hidden: |
|
||||
//rank=same
|
||||
//style=invis
|
||||
node:
|
||||
text: |
|
||||
shape=plaintext
|
||||
@ -17,7 +22,7 @@ dot:
|
||||
height=0
|
||||
edge:
|
||||
default: |
|
||||
headport=n
|
||||
tailport=s
|
||||
//headport=n
|
||||
//tailport=s
|
||||
hidden: |
|
||||
style=invis
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
Before Width: | Height: | Size: 138 KiB After Width: | Height: | Size: 139 KiB |
@ -6,5 +6,6 @@ services:
|
||||
dockerfile: Dockerfile
|
||||
image: puudot:latest
|
||||
volumes:
|
||||
- ./code:/code
|
||||
- ./data:/data
|
||||
- ./config.yaml:/config.yaml
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user