# AssembleCcdTask failure with Python 2

XMLWordPrintable

#### Details

• Type: Story
• Status: Done
• Resolution: Done
• Fix Version/s: None
• Component/s:
• Labels:
• Story Points:
0.5
• Sprint:
• Team:

#### Description

 Traceback (most recent call last):  File "runAssembleTask.py", line 36, in   runAssembler()  File "runAssembleTask.py", line 21, in runAssembler  assembledExposure = assembleTask.assembleCcd(assemblyInput)  File "/scratch/swinbank/ip_isr/python/lsst/ip/isr/assembleCcdTask.py", line 200, in assembleCcd  ccd = next(assembleInput.values()).getDetector() TypeError: list object is not an iterator 

Looks like a bad conversion to Python 3: it assumes that dict.values() returns an iterator, but in Python 2 it returns a list. Simple (but ugly) fix:

 --- a/python/lsst/ip/isr/assembleCcdTask.py +++ b/python/lsst/ip/isr/assembleCcdTask.py @@ -197,7 +197,7 @@ class AssembleCcdTask(pipeBase.Task):  ccd = None  if hasattr(assembleInput, "has_key"):  # Get a detector object for this set of amps - ccd = next(assembleInput.values()).getDetector() + ccd = next(iter(assembleInput.values())).getDetector()  # Sent a dictionary of input exposures, assume one amp per key keyed on amp name    def getNextExposure(amp): 

Better suggestions welcome.

Rather shocking that this wasn't caught by tests. Sufficiently shocking that I'm wondering if I missed something. I suggest that rather than just committing the above tweak, this ticket should include a test which demonstrates that the task actually runs. An easy way to do that might be to simply migrate a slightly modified version of the code from examples/ to tests/.

#### Activity

Hide
Merlin Fisher-Levine added a comment -

PS This ticket is duplicated now by https://jira.lsstcorp.org/browse/DM-9370 which I just filed. Not sure whether to delete that or what, but presumable John Swinbank can help me clean up the mess :/

Show
Merlin Fisher-Levine added a comment - PS This ticket is duplicated now by https://jira.lsstcorp.org/browse/DM-9370 which I just filed. Not sure whether to delete that or what, but presumable John Swinbank can help me clean up the mess :/
Hide
Simon Krughoff added a comment - - edited

Sorry that I missed this till now. I bet we can find someone to do it around here.

Edit: Russell Owen said he'd take it on ASAP. We have a workshop tomorrow, but after that.

Show
Simon Krughoff added a comment - - edited Sorry that I missed this till now. I bet we can find someone to do it around here. Edit: Russell Owen said he'd take it on ASAP. We have a workshop tomorrow, but after that.
Hide
Merlin Fisher-Levine added a comment -

I have fixed on a ticket branch in DM-9370, but I don't know if this is the fix people want. It works, but it doesn't get around the fact that this should have been caught by tests. Not sure whether to submit for review or now...

Show
Merlin Fisher-Levine added a comment - I have fixed on a ticket branch in DM-9370 , but I don't know if this is the fix people want. It works, but it doesn't get around the fact that this should have been caught by tests. Not sure whether to submit for review or now...
Hide
Russell Owen added a comment -

I fixed the code but posponed a unit test for DM-9374. The fix is straightforward. Please see if this works for you.

Show
Russell Owen added a comment - I fixed the code but posponed a unit test for DM-9374 . The fix is straightforward. Please see if this works for you.
Hide
Merlin Fisher-Levine added a comment -

Looks good to me!

Show
Merlin Fisher-Levine added a comment - Looks good to me!

#### People

Assignee:
Russell Owen
Reporter:
John Swinbank
Reviewers:
Merlin Fisher-Levine
Watchers:
John Parejko, John Swinbank, Mandeep Gill [X] (Inactive), Merlin Fisher-Levine, Russell Owen, Simon Krughoff, Tim Jenness