cloudmesh / cloudmesh-flow

Workflow for cloudmesh
Other
1 stars 1 forks source link

IMPORTANT: simplified dict return from db #13

Closed laszewsk closed 5 years ago

laszewsk commented 5 years ago

I think there may be an issue with the database implementation.

why are we not just returning a dict representing the flow. THis woudl make things I guess easier? we could than use our flatten dict method so you could get easily values for the display, I think your Node object ignores all of them but I was not sure? so the list would just return an arry of dicts of the form shown next.

{
    "name" : "a",
    "dependencies" : [],
    "workflow" : "workflow",
    "cm" : {
        "kind" : "flow",
        "cloud" : "workflow",
        "name" : "a",
        "collection" : "workflow-flow",
        "created" : "2019-04-21 10:09:14.653231",
        "modified" : "2019-04-21 10:09:14.653231"
    },
    "kind" : "flow",
    "cloud" : "workflow"
}
laszewsk commented 5 years ago

so you do not have to fix this but here is a way on how to list the nodes as dict

        db = CmDatabase()
        nodes = db.find(collection=f"{arguments.FLOWNAME}-flow")

        order = ["name", "workflow", "dependencies", "cm.modified"]
        header = ["Name", "Workflow", "Dependencies", "Modified"]

        for node in nodes:
            node["dependencies"] = ", ".join(node["dependencies"])

        print(Printer.flatwrite(nodes,
                                order=order,
                                header=header,
                                output=arguments.output))

this can be used as example not yet sure how the viz comom=nent does it

robludwig commented 5 years ago

This is now the default list code for the command line.

For the WorkFlowDB class, I am reluctant to change as that would break the format used in the visualization portion. Best to leave this to after the freeze ends on the viz component.

laszewsk commented 5 years ago

please make sure your documentatio in the manual, contains the description how the db object looks like. Just in case I reopened this. If you alread ydid that, close this issue again with the comment that db object is documented in the manual

robludwig commented 5 years ago

Created new docs in manual. Should be good