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-40517: add unit test for quickLook #77

Merged
merged 9 commits into from Jan 27, 2024
Merged

DM-40517: add unit test for quickLook #77

merged 9 commits into from Jan 27, 2024

Conversation

isullivan
Copy link
Contributor

No description provided.

Copy link
Contributor

@mfisherlevine mfisherlevine left a comment

Choose a reason for hiding this comment

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

This looks really great as a set of tests in general, and I think is really worth adding! There's one moderately-sized problem though: the issue before was in the actual command line task construction & execution (the connection magic), and this still doesn't get that tested with these changes. I reverted Jim's fix on DM-40512 to check, and the task then fails on the command line, but these tests still pass. I'm not sure exactly of the best way of testing this, but I thought that perhaps a SimplePipelineExector might be the way to go, as this will run it via the same machinery as the command line does.

@isullivan isullivan force-pushed the tickets/DM-40517 branch 3 times, most recently from 8e69d20 to b058434 Compare January 26, 2024 07:13
@isullivan isullivan force-pushed the tickets/DM-40517 branch 2 times, most recently from a0d71df to 6255483 Compare January 26, 2024 07:30
@isullivan
Copy link
Contributor Author

I added a unit test that sets up a test butler with the necessary datasets, and which fails with the unmodified quickLook. I then fixed quickLook so that the new test passes, and that fixes the example pipetask run command at the USDF.

Comment on lines 242 to 243
except AttributeError:
bfGains = None
Copy link
Contributor

Choose a reason for hiding this comment

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

If a newBFKernel is supplied but we fail to pull the gains out then I'd think we'd probably want to at least log a warning here. What's your thinking on why this shouldn't be a raise though?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe I took the statement "Should never fail" in the docstring of this task too literally! I'm happy to either log a warning or let it raise, your choice.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, yeah, I see, I did wonder if it was something like that. I mean, it should never fail based if valid things are being passed in, but if, say, a calib was the wrong size or something truly awful like that then I think in those cases it should still raise tbh, otherwise the behaviour is sort of ill-defined. Everything that's passed in should work, and if it doesn't then I think that's raise-time. All the other raises like that are implicit and come from isrTask raising though, so I think raising here is fine.

result = isrTask.run(ccdExposure,
camera=camera,
bias=bias,
dark=dark,
flat=flat,
# fringes=pipeBase.Struct(fringes=None),
fringes=fringes,
Copy link
Contributor

Choose a reason for hiding this comment

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

Now that we're actually accepting the fringes if they're passed in, I think we should also have a block that tests if we got fringes supplied, and if so, sets the config option on to use them. We can then remove the # TODO: deal with fringes here comment too 🙂

Copy link
Contributor

Choose a reason for hiding this comment

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

I think just replacing that TODO with

        if fringes.fringes is not None:
            isrConfig.doFringe = True
            self.log.info("Running with fringe correction")

should do it.

Comment on lines 94 to 95
# Pass in IsrTask so that we can modify it slightly for unit tests.
self.isrTask = IsrTask
Copy link
Contributor

Choose a reason for hiding this comment

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

This took me longer to understand than I care to admit, so I think a slightly more thorough comment might be useful here. Perhaps something along the lines of

        # Pass in IsrTask so that we can modify it slightly for unit tests.
        # Note that this is not an instance of the IsrTask class, but the class
        # itself, which is then instantiated later on, in the run() method,
        # with the dynamically generated config.



class QuickLookIsrTaskTestCase(unittest.TestCase):

Copy link
Contributor

Choose a reason for hiding this comment

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

Spurious newline.

linearizer = "linearizer"
fringes = "fringe"
sensorTransmission = "transmission_sensor"
crosstalkSources = "isrOverscanCorrected"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is that true?! I mean, I don't doubt you at all, but that's a horrible name mapping!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Wow, OK, thanks!

butlerTests.addDataIdValue(self.repo, "instrument", instrument)
butlerTests.addDataIdValue(self.repo, "physical_filter", physical_filter, band=band)
butlerTests.addDataIdValue(self.repo, "detector", detector)
# butlerTests.addDataIdValue(self.repo, "detector", detector + 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this commented line be removed? Or was the plan to iterate over this option and check it raises for a detector id mismatch?

Comment on lines 254 to 261
# Turn on all optional inputs
config.doAttachTransmissionCurve = True
config.doIlluminationCorrection = True
config.doStrayLight = True
config.doDeferredCharge = True
config.usePtcReadNoise = True
config.doCrosstalk = True
config.doBrighterFatter = False
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a little confused by this block in two small ways: it says to turn on all option inputs, but it doesn't include many (mostly the main ones, like bias/dark/flat etc), and also config.doBrighterFatter is set to False whereas all the others are True. Could you just clarify?

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 catch! I forgot to turn this back on after I got BF working.

@isullivan isullivan merged commit 2fd5394 into main Jan 27, 2024
1 check passed
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