Skip to content

Commit

Permalink
Merge pull request #28 from cadbuildr/fix-head-node-id
Browse files Browse the repository at this point in the history
dag format
  • Loading branch information
clement91190 authored Apr 22, 2024
2 parents c9a83cf + 8b3f0b0 commit c57c905
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/foundation/utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from foundation.types.component import Component
from foundation.types.assembly import Assembly
from foundation.types.serializable import serializable_nodes
from foundation.geometry.plane import PlaneFromFrame, PlaneFactory
import numpy as np
import sys

DAG_VERSION_FORMAT = "1.0"


# TODO clean this code to remove copy paste

Expand Down Expand Up @@ -66,6 +69,24 @@ def check_dict(d) -> None:
print(k, v)


def format_dag(dag: dict):
"""Format the DAG to include extra information :
- the serializable nodes
- format version
- root node id
@param dag: the DAG to format ( see to_dag functions.)
"""
# first of the key :

return {
"version": DAG_VERSION_FORMAT,
"rootNodeId": next(iter(dag.keys())),
"DAG": dag,
"serializableNodes": serializable_nodes,
}


def show(component: Component) -> None:
"""Function that is actually mocked on
server and browser, but not on the tests"""
Expand Down
3 changes: 2 additions & 1 deletion src/foundation/utils_ext.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from foundation.types.component import Component

from foundation.utils import format_dag

try:
import json
Expand All @@ -18,6 +18,7 @@ def create_connection(*args, **kwargs):

def showExt(component: Component) -> None:
dic = component.to_dag()
dic = format_dag(dic)

try:
ws = websocket.create_connection("ws://127.0.0.1:3000")
Expand Down

0 comments on commit c57c905

Please sign in to comment.