Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-21390: Add a show option to examine a qgraph #27

Merged
merged 2 commits into from Oct 11, 2019
Merged

Conversation

hsinfang
Copy link
Contributor

No description provided.

Copy link
Collaborator

@andy-slac andy-slac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks OK, few comments/suggestions below.

def _showWorkflow(self, graph, args):
"""Print quanta information and dependency to stdout

The input and pridicted output URIs based on the Butler repo are printed.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo pridicted

node = QuantumGraphTaskNodes(taskNodes.taskDef, [quantum],
quantum.initInputs, quantum.outputs)
qgraph = QuantumGraph()
qgraph.append(node)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Combine two lines into a shorter qgraph = QuantumGraph([node])?

Maybe we should also move this operation that splits one QGraph into multiple single-quantum QGraphs into the Graph class itself, if that is a useful operation by itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how useful it is beyond small test workflows, but moving it to the QuantumGraph class makes sense, and indeed seems safer with potential implementation changes of the class itself.
I created lsst/pipe_base#103 for it.

hash2ParentTask = {}
for taskNodes in graph:
for quantum in taskNodes.quanta:
iq += 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably make iteration in one loop:

for iq, (taskDef, quantum) in enumerate(graph.quanta()):

There is a chance that implementation of the QuantumGraph will change (making it a subclass of a list was probably wrong decision), quanta() method should be safer w.r.t. potential changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quanta() is a useful method. Thanks for bringing it up.

iq += 1
shortname = taskNodes.taskDef.taskName.split('.')[-1]
print("Quantum {}: {}".format(iq, shortname))
if args.save_qgraph:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, reusing the same --save-qgraph can have a surprising effect, that will also save full graph and can inadvertently override existing data if you are not careful. It may be better to introduce new special option like --save-single-quanta which takes the file name pattern (e.g. --save-single-quanta=single-quantum-{}.pickle). I'd probably made this new option independent of --show=workflow or explicitly mention that it only works with --show=workflow if you prefer current way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Done.

Related to this, about the QuantumGraph.quanta() method, for one same given QuantumGraph, I understand quanta are returned in unspecified order (as said in its doc), but is it okay to assume that order is the same in multiple invocations? (Looks fine in the current list implementation, but maybe not guaranteed in the future?)

hash2ParentTask[dhash] = iq

iq = 0
uses = []
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably use set instead of list here, searching in a set should be faster.

@hsinfang hsinfang force-pushed the tickets/DM-21390 branch 2 times, most recently from b9b6743 to bb70868 Compare October 11, 2019 17:38
@hsinfang hsinfang merged commit 27d0315 into master Oct 11, 2019
@timj timj deleted the tickets/DM-21390 branch April 23, 2020 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants