Skip to content

Commit

Permalink
Add construct doxygen command to Gather and Scatter components. Updat…
Browse files Browse the repository at this point in the history
…e xml2palette to produce constructs around components where construct commands were found.
  • Loading branch information
james-strauss-uwa committed Mar 1, 2022
1 parent 6ec19ca commit c706ebc
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 14 deletions.
3 changes: 3 additions & 0 deletions daliuge-engine/dlg/apps/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ def averageArray(self):
# @details A BarrierAppDrop that combines one or more inputs using cummulative operations.
# @par EAGLE_START
# @param category PythonApp
# @param construct Gather
# @param tag daliuge
# @param[in] cparam/appclass Application Class/dlg.apps.simple.GenericNpyGatherApp/String/readonly/False//False/
# \~English Application class
Expand Down Expand Up @@ -610,6 +611,7 @@ def run(self):
# resulting array.
# @par EAGLE_START
# @param category PythonApp
# @param construct Scatter
# @param tag daliuge
# @param[in] cparam/appclass Application Class/dlg.apps.simple.GenericScatterApp/String/readonly/False//False/
# \~English Application class
Expand Down Expand Up @@ -679,6 +681,7 @@ def run(self):
# resulting array.
# @par EAGLE_START
# @param category PythonApp
# @param construct Scatter
# @param tag daliuge
# @param[in] cparam/appclass Application Class/dlg.apps.simple.GenericNpyScatterApp/String/readonly/False//False/
# \~English Application class
Expand Down
80 changes: 66 additions & 14 deletions tools/xml2palette/xml2palette.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
]

KNOWN_PARAM_DATA_TYPES = ["String", "Integer", "Float", "Complex", "Boolean", "Select", "Password", "Json"]
KNOWN_CONSTRUCT_TYPES = ["Scatter", "Gather"]


def get_options_from_command_line(argv):
inputdir = ""
Expand Down Expand Up @@ -479,6 +481,7 @@ def create_palette_node_from_params(params):
description = ""
category = ""
tag = ""
construct = ""
categoryType = ""
inputPorts = []
outputPorts = []
Expand All @@ -497,6 +500,8 @@ def create_palette_node_from_params(params):

if key == "category":
category = value
elif key == "construct":
construct = value
elif key == "tag":
tag = value
elif key == "text":
Expand Down Expand Up @@ -661,14 +666,11 @@ def create_palette_node_from_params(params):
add_required_fields_for_category(text, fields, category)

# create and return the node
# TODO: we can remove a bunch of these attributes (isData etc)
return {
return ({
"tag": tag, "construct": construct
},
{
"category": category,
"tag": tag,
"isData": False,
"isGroup": False,
"canHaveInputs": True,
"canHaveOutputs": True,
"drawOrderHint": 0,
"key": get_next_key(),
"text": text,
Expand All @@ -681,10 +683,8 @@ def create_palette_node_from_params(params):
"expanded": False,
"inputApplicationName": "",
"outputApplicationName": "",
"exitApplicationName": "",
"inputApplicationType": "None",
"outputApplicationType": "None",
"exitApplicationType": "None",
"inputPorts": inputPorts,
"outputPorts": outputPorts,
"inputLocalPorts": inputLocalPorts,
Expand All @@ -695,7 +695,7 @@ def create_palette_node_from_params(params):
"applicationArgs": applicationArgs,
"git_url": gitrepo,
"sha": version,
}
})


def write_palette_json(outputfile, nodes, gitrepo, version):
Expand Down Expand Up @@ -826,6 +826,52 @@ def process_compounddef(compounddef):
return result


def create_construct_node(type, node):

# check that type is in the list of known types
if type not in KNOWN_CONSTRUCT_TYPES:
logging.warning(
text + " construct for node'" + node["text"] + "' has unknown type: " + type
)

construct_node = {
"applicationArgs": [],
"category": type,
"description": "A default " + type + " construct for the " + node["text"] + " component.",
"fields": [],
"applicationArgs": [],
"git_url": gitrepo,
"key": get_next_key(),
"precious": False,
"sha": version,
"streaming": False,
"text": "Scatter" + "/" + node["text"]
}

if type == "Scatter" or type == "Gather":
construct_node["inputAppFields"] = node["fields"]
construct_node["inputAppArgs"] = node["applicationArgs"]
construct_node["inputApplicationKey"] = node["key"]
construct_node["inputApplicationName"] = node["text"]
construct_node["inputApplicationType"] = node["category"]
construct_node["inputApplicationDescription"] = node["description"]
construct_node["inputLocalPorts"] = node["outputPorts"]
construct_node["inputPorts"] = node["inputPorts"]
construct_node["outputAppFields"] = []
construct_node["outputAppArgs"] = []
construct_node["outputApplicationKey"] = None
construct_node["outputApplicationName"] = ""
construct_node["outputApplicationType"] = "None"
construct_node["outputApplicationDescription"] = ""
construct_node["outputLocalPorts"] = []
construct_node["outputPorts"] = []
else:
pass # not sure what to do for other types like MKN yet

return construct_node



if __name__ == "__main__":
logging.basicConfig(format="%(asctime)s - %(message)s", datefmt="%d-%b-%y %H:%M:%S", level = logging.INFO)

Expand Down Expand Up @@ -900,12 +946,18 @@ def process_compounddef(compounddef):
# print("params (" + str(len(params)) + "): " + str(params))

# create a node
n = create_palette_node_from_params(params)
data, node = create_palette_node_from_params(params)

# if the node tag matches the command line tag, or no tag was specified on the command line, add the node to the list to output
if n["tag"] == tag or tag == "":
logging.info("Adding component: " + n["text"])
nodes.append(n)
if data["tag"] == tag or tag == "":
logging.info("Adding component: " + node["text"])
nodes.append(node)

# if a construct is found, add to nodes
if data["construct"] != "":
logging.info("Adding component: " + data["construct"] + "/" + node["text"])
construct_node = create_construct_node(data["construct"], node)
nodes.append(construct_node)

# check if gitrepo and version params were found and cache the values
for param in params:
Expand Down

0 comments on commit c706ebc

Please sign in to comment.