Skip to content

Commit

Permalink
Import blockdag into xml2palette and create signature for palette
Browse files Browse the repository at this point in the history
  • Loading branch information
james-strauss-uwa committed Aug 12, 2022
1 parent 5ebddd9 commit 0134ecd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/create-palettes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
- name: Install system dependencies
run: |
sudo apt-get update && sudo apt-get install -y doxygen xsltproc
pip install BlockDAG
- name: Configure git
run: |
Expand Down
17 changes: 15 additions & 2 deletions tools/xml2palette/xml2palette.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import math
from enum import Enum

from blockdag import build_block_dag

next_key = -1

# NOTE: not sure if all of these are actually required
Expand Down Expand Up @@ -73,6 +75,14 @@
"OutputPort"
]

BLOCKDAG_DATA_FIELDS = [
"inputPorts",
"outputPorts",
"applicationArgs",
"category",
"fields"
]

class Language(Enum):
UNKNOWN = 0
C = 1
Expand Down Expand Up @@ -542,7 +552,7 @@ def create_palette_node_from_params(params):
)


def write_palette_json(outputfile, nodes, gitrepo, version):
def write_palette_json(outputfile, nodes, gitrepo, version, signature):
palette = {
"modelData": {
"fileType": "palette",
Expand All @@ -553,6 +563,7 @@ def write_palette_json(outputfile, nodes, gitrepo, version):
"filePath": outputfile,
"sha": version,
"git_url": gitrepo,
"signature": signature
},
"nodeDataArray": nodes,
"linkDataArray": [],
Expand Down Expand Up @@ -1052,9 +1063,11 @@ def params_to_nodes(params):
if not alreadyPresent:
nodes.append(n)

# add signature for whole palette using BlockDAG
palette_signature = build_block_dag(nodes, [], data_fields=BLOCKDAG_DATA_FIELDS)

# write the output json file
write_palette_json(outputfile, nodes, gitrepo, version)
write_palette_json(outputfile, nodes, gitrepo, version, palette_signature)
logging.info("Wrote " + str(len(nodes)) + " component(s)")

# cleanup the output directory
Expand Down

0 comments on commit 0134ecd

Please sign in to comment.