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-38377: Fix label order bugs found by rescue workflows. #139

Merged
merged 1 commit into from Apr 6, 2023

Conversation

MichelleGower
Copy link
Collaborator

@MichelleGower MichelleGower commented Apr 4, 2023

Checklist

  • ran Jenkins
  • added a release note for user-visible changes to doc/changes

@codecov
Copy link

codecov bot commented Apr 4, 2023

Codecov Report

Patch coverage: 95.04% and project coverage change: +1.34 🎉

Comparison is base (80bbc1b) 78.65% compared to head (8476afe) 80.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #139      +/-   ##
==========================================
+ Coverage   78.65%   80.00%   +1.34%     
==========================================
  Files          39       40       +1     
  Lines        2863     3015     +152     
  Branches      489      511      +22     
==========================================
+ Hits         2252     2412     +160     
+ Misses        535      514      -21     
- Partials       76       89      +13     
Impacted Files Coverage Δ
python/lsst/ctrl/bps/clustered_quantum_graph.py 73.56% <50.00%> (+17.01%) ⬆️
python/lsst/ctrl/bps/generic_workflow.py 81.79% <86.53%> (+0.35%) ⬆️
python/lsst/ctrl/bps/quantum_clustering_funcs.py 97.29% <96.19%> (-1.91%) ⬇️
tests/test_clustered_quantum_graph.py 97.61% <97.61%> (ø)
python/lsst/ctrl/bps/transform.py 68.86% <100.00%> (-0.69%) ⬇️
tests/cqg_test_utils.py 98.75% <100.00%> (+0.44%) ⬆️
tests/test_generic_workflow.py 98.84% <100.00%> (-0.14%) ⬇️
tests/test_quantum_clustering_funcs.py 98.19% <100.00%> (+0.13%) ⬆️
tests/test_transform.py 89.69% <100.00%> (-7.22%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@MichelleGower MichelleGower marked this pull request as ready for review April 5, 2023 02:25

class GenericWorkflowLabels:
"""A generic representation of a workflow used to submit to specific
workflow management systems.
Copy link
Contributor

Choose a reason for hiding this comment

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

The docstring needs to be updated.

@@ -181,7 +182,7 @@ def create_init_workflow(config, qgraph, qgraph_gwfile):
init_workflow.add_file(qgraph_gwfile)

# create job for executing --init-only
gwjob = GenericWorkflowJob("pipetaskInit")
gwjob = GenericWorkflowJob("pipetaskInit", "pipetaskInit")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rewrite it as

gwjob = GenericWorkflowJob("pipetaskInit", label="pipetaskInit")

to improve readability.

if not self._label_to_jobs[job.label]:
del self._label_to_jobs[job.label]

# remove from graph
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment seems a little bit redundant. I'd remove it.

cqg = ClusteredQuantumGraph("cqg1", qgraph, f"{outdir}/test_file.qgraph")

# since random hash ids, create mapping for tests
test_lookup = {} # since random hash ids, provide mapping for tests
Copy link
Contributor

Choose a reason for hiding this comment

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

Repeated comment, please remove one of them.

Directed graph of tasks.

Returns
-------
task_labels : `set` [`str`]
Set of task labels from the cluster definitions.
cluster_labels: `list`
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to specify the type of the elements as well.

# T2(1,2) T2(3,4)
# | |
# T3(1,2) T3(3,4)
def make_test_clustered_quantum_graph(outdir):
Copy link
Contributor

Choose a reason for hiding this comment

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

As this function is (sort of) a part of the public API, adding a docstring would be nice.

quantum_to_cluster : `dict` [ `str`, `str` ]
Mapping of quantum node id to which cluster it was added.
(modified in method)
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

The docstring doesn't mentioned that the function raises KeyError. Please add the relevant section.

for tdef in task_graph:
label_graph.add_node(tdef.label)
for parent in task_graph.predecessors(tdef):
label_graph.add_edge(parent.label, tdef.label)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just FYI, you could potentially replace lines 125-127 with

label_graph.add_edges_from([(parent.label, tdef.label) for parent in task_graph.predecessors(tdef)])

As a side note, you could even "collapse" lines 124-127 to

label_graph.add_edges_from([(parent.label, tdef.label) for tdef in task_graph for parent in task_graph.predecessors(tdef)])

but I feel like it actually make code less readable in this case. So I'm leaving the final decision up to you (which may include making no changes whatsoever).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm going to leave the code the way it is for this ticket.

@MichelleGower MichelleGower merged commit 85f76e3 into main Apr 6, 2023
10 checks passed
@MichelleGower MichelleGower deleted the tickets/DM-38377 branch April 6, 2023 01:46
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