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-35817: Turn off compatibility mode as the default. #229

Merged
merged 1 commit into from Aug 5, 2022

Conversation

isullivan
Copy link
Contributor

Also set the default convolution mode to convolveTemplate

Copy link
Contributor

@parejkoj parejkoj left a comment

Choose a reason for hiding this comment

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

A few suggestions, since I'd just been working on this for DM-971.

Please reword the commit message to say why you defaulted mode="convolveTemplate": it's not obvious at first glance why that's related to here (I'm assuming because that's our transition plan).

if self.forceCompatibility:
self.mode = "convolveTemplate"
if self.forceCompatibility and not (self.mode == "convolveTemplate"):
raise ValueError("If forceCompatibility=True, then mode='convolveTemplate' must also be set")
Copy link
Contributor

Choose a reason for hiding this comment

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

Here's my suggestion for the internals fo the if; FieldValidationError gives some useful extra context.

            raise lsst.pex.config.FieldValidationError(AlardLuptonSubtractConfig.forceCompatibility,
                                                       self, msg)

@@ -252,6 +255,7 @@ def _run_and_check_images(statsCtrl, statsCtrlDetect, scienceNoiseLevel, templat
config = subtractImages.AlardLuptonSubtractTask.ConfigClass()
config.doSubtractBackground = False
config.forceCompatibility = 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 would remove all the config.forceCompatibility = False lines from all the tests, since it now defaults to that.

@@ -155,6 +155,9 @@ def test_config_validate_forceCompatibility(self):
config = subtractImages.AlardLuptonSubtractTask.ConfigClass()
config.mode = "auto"
config.forceCompatibility = True
with self.assertRaises(ValueError):
config.validate()
config.mode = 'convolveTemplate'
Copy link
Contributor

Choose a reason for hiding this comment

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

Here's what I'd done (after the forceCompatibility=True line), and removing the two lines below:

        # Ensure we're not trying to change config values inside validate().
        config.freeze()
        with self.assertRaisesRegex(FieldValidationError,
                                    "forceCompatibility=True requires mode='convolveTemplate'"):
            config.validate()

        config = subtractImages.AlardLuptonSubtractTask.ConfigClass()
        config.mode = "convolveTemplate"
        config.forceCompatibility = True
        # Ensure we're not trying to change config values inside validate().
        config.freeze()
        # Should not raise:
        config.validate()

Copy link
Contributor

@parejkoj parejkoj left a comment

Choose a reason for hiding this comment

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

One tweak to the exception text, otherwise this is good. Thanks for fixing this on this ticket, so I don't have to on DM-971.

if self.forceCompatibility:
self.mode = "convolveTemplate"
if self.forceCompatibility and not (self.mode == "convolveTemplate"):
msg = "forceCompatibility=True requires mode='convolveTemplate'"
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I forgot to include one thing in my suggestion: but mode was '{self.mode}'" at the end of this message (and make it an f-string).

Also set the default convolution mode to `convolveTemplate`.
This is the next step in our transition to the refactored image differencing,
which preserves the default functionality of always convolving the template.
With `forceCompatibility=False` we can use the new code to fix a few bugs that were
present in the old ImageDifferenceTask.

Update subtractImages config validation.
@isullivan isullivan merged commit 8c31ad8 into main Aug 5, 2022
@isullivan isullivan deleted the tickets/DM-35817 branch August 5, 2022 22:47
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