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-27209: Update for new quantum graph API #7
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions on how to do these operations more efficiently. What you wrote seems like it will work, so take whatever info you think is best.
bin.src/exportGraphInputs.py
Outdated
for quantum_node in graph: | ||
for key, value in quantum_node.quantum.inputs.items(): | ||
for dataset in value: | ||
if dataset.datasetType.name not in dataset_types_to_exclude: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quantum.inputs
is already a mapping of DatasetType
. As it is now, key
is not used. If this was rearranged to:
...
for key, value in quantum_node.quantum.inputs.items():
if key.name not in dataset_types_to_exclude:
found = {butler.registiry.queryDatasets(key.name, collections=..., dataId=dataset.dataId) for dataId in value}
...
It would save a for loop over a lot of elements that will be excluded by dataset_types_to_exclude
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have rejigged a bit based on the suggestion above but I can't use that line that does the loop over refs in queryDatasets because queryDatasets returns an interator and not DatasetRef and so you end up with a set of iterators. It's easier to use still use an explicit loop over refs (but still inside the if-check).
One thing that does confuse me is that the quantum_node.quantum.inputs
is returning a proper DatasetRef with the id
attached so the reality is that this queryDataset call is returning the same thing it had to start with. Not entirely sure that we expect that or not so maybe it's a special case for this particular example.
bin.src/exportGraphInputs.py
Outdated
for key, value in quantum_node.quantum.inputs.items(): | ||
for dataset in value: | ||
if dataset.datasetType.name in ("raw",): | ||
items.append(dataset) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would better be written as:
for quantum_node in graph.findQuantaWithDSType("raw"):
if "raw" in quantum_node.quantum.inputs: # Verify that raw is an input and not an output
items.extend(quantum_node.quantum.inputs["raw"])
This should cut down on the number of iterations as findQuantaWithDSType
uses precomputed dictionaries.
6e10747
to
a7f8b7c
Compare
No description provided.