-
Notifications
You must be signed in to change notification settings - Fork 4
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-25222: Fix handling of skip-existing in PreExecInit #55
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# This file is part of ctrl_mpexec. | ||
# | ||
# Developed for the LSST Data Management System. | ||
# This product includes software developed by the LSST Project | ||
# (https://www.lsst.org). | ||
# See the COPYRIGHT file at the top-level directory of this distribution | ||
# for details of code ownership. | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
"""Simple unit test for PreExecInit class. | ||
""" | ||
|
||
import unittest | ||
|
||
from lsst.ctrl.mpexec import PreExecInit | ||
from testUtil import makeSimpleQGraph, AddTaskFactoryMock | ||
|
||
|
||
class PreExecInitTestCase(unittest.TestCase): | ||
"""A test case for PreExecInit | ||
""" | ||
|
||
def test_saveInitOutputs(self): | ||
taskFactory = AddTaskFactoryMock() | ||
for skipExisting in (False, True): | ||
with self.subTest(skipExisting=skipExisting): | ||
butler, qgraph = makeSimpleQGraph() | ||
preExecInit = PreExecInit(butler=butler, taskFactory=taskFactory, skipExisting=skipExisting) | ||
preExecInit.saveInitOutputs(qgraph) | ||
|
||
def test_saveInitOutputs_twice(self): | ||
taskFactory = AddTaskFactoryMock() | ||
for skipExisting in (False, True): | ||
with self.subTest(skipExisting=skipExisting): | ||
butler, qgraph = makeSimpleQGraph() | ||
preExecInit = PreExecInit(butler=butler, taskFactory=taskFactory, skipExisting=skipExisting) | ||
preExecInit.saveInitOutputs(qgraph) | ||
if skipExisting: | ||
# will ignore this | ||
preExecInit.saveInitOutputs(qgraph) | ||
else: | ||
# Second time it will fail | ||
with self.assertRaises(Exception): | ||
preExecInit.saveInitOutputs(qgraph) | ||
|
||
def test_saveConfigs(self): | ||
for skipExisting in (False, True): | ||
with self.subTest(skipExisting=skipExisting): | ||
butler, qgraph = makeSimpleQGraph() | ||
preExecInit = PreExecInit(butler=butler, taskFactory=None, skipExisting=skipExisting) | ||
preExecInit.saveConfigs(qgraph) | ||
|
||
def test_saveConfigs_twice(self): | ||
for skipExisting in (False, True): | ||
with self.subTest(skipExisting=skipExisting): | ||
butler, qgraph = makeSimpleQGraph() | ||
preExecInit = PreExecInit(butler=butler, taskFactory=None, skipExisting=skipExisting) | ||
preExecInit.saveConfigs(qgraph) | ||
if skipExisting: | ||
# will ignore this | ||
preExecInit.saveConfigs(qgraph) | ||
else: | ||
# Second time it will fail | ||
with self.assertRaises(Exception): | ||
preExecInit.saveConfigs(qgraph) | ||
|
||
def test_savePackageVersions(self): | ||
for skipExisting in (False, True): | ||
with self.subTest(skipExisting=skipExisting): | ||
butler, qgraph = makeSimpleQGraph() | ||
preExecInit = PreExecInit(butler=butler, taskFactory=None, skipExisting=skipExisting) | ||
preExecInit.savePackageVersions(qgraph) | ||
|
||
def test_savePackageVersions_twice(self): | ||
for skipExisting in (False, True): | ||
with self.subTest(skipExisting=skipExisting): | ||
butler, qgraph = makeSimpleQGraph() | ||
preExecInit = PreExecInit(butler=butler, taskFactory=None, skipExisting=skipExisting) | ||
preExecInit.savePackageVersions(qgraph) | ||
if skipExisting: | ||
# if this is the same packages then it should not attempt to save | ||
preExecInit.savePackageVersions(qgraph) | ||
else: | ||
# second time it will fail | ||
with self.assertRaises(Exception): | ||
preExecInit.savePackageVersions(qgraph) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Datastore.get does check that the returned python object is an instance of the StorageClass python type. It does not require that types match directly. Your test here is more stringent than butler -- does it ever trigger?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea, probably not because we did not see any questions/complaints about this. What we want to do is to make sure that objects are identical but there is no way to do it now for arbitrary types, checking that types are identical is the minimum that we can do here.