Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-8355

AssembleCcdTask failure with Python 2

    XMLWordPrintable

    Details

    • Story Points:
      0.5
    • Epic Link:
    • Sprint:
      Alert Production S17 - 2
    • Team:
      Alert Production

      Description

      E.g. when running ip_isr's examples/runAssembleTask.py:

      Traceback (most recent call last):
        File "runAssembleTask.py", line 36, in <module>
          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/.

        Attachments

          Issue Links

            Activity

            Hide
            mfisherlevine 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
            mfisherlevine 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
            krughoff 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
            krughoff 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
            mfisherlevine 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
            mfisherlevine 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
            rowen 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
            rowen 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
            mfisherlevine Merlin Fisher-Levine added a comment -

            Looks good to me!

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

              People

              Assignee:
              rowen Russell Owen
              Reporter:
              swinbank John Swinbank
              Reviewers:
              Merlin Fisher-Levine
              Watchers:
              John Parejko, John Swinbank, Mandeep Gill [X] (Inactive), Merlin Fisher-Levine, Russell Owen, Simon Krughoff, Tim Jenness
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  CI Builds

                  No builds found.