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-17004: JointcalRunner.__call__ not receiving "butler" in kwargs #130

Merged
merged 1 commit into from Mar 22, 2019

Conversation

parejkoj
Copy link
Collaborator

No description provided.

Copy link
Member

@timj timj left a comment

Choose a reason for hiding this comment

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

My main comment is that there needs to be more commenting on what is going on. JointCalRunner is seemingly mocked and Butler is mocked so you have to explain what code is being tested.

"""Test that JointcalRunner calls JointcalTask with appropriate arguments."""
@classmethod
def setUpClass(cls):
cls.data_dir = os.path.join(lsst.utils.getPackageDir('jointcal'), 'tests/data')
Copy link
Member

Choose a reason for hiding this comment

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

I strongly prefer that directories like this are calculated relative to __file__ rather than requiring getPackageDir to work. Also, I think this can be calculated once at the top of the file and doesn't need to be calculated in setUpClass.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why do you prefer to put it at the top of the file instead of in setUpClass? setUpClass is where "do this once" things go.

Copy link
Member

Choose a reason for hiding this comment

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

Both places work, but I tend to prefer putting calculations at file scope that are fixed for the file and I would use setUpClass or setUp to calculate values derived from that fixed global.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why do you prefer using __file__ to getPackageDir? The former requires three nested os.path.blah things.

Copy link
Member

Choose a reason for hiding this comment

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

Because I don't believe that a third party package should be used to find some test data that is in the directory below the test script itself. I also think that if I run this test script in isolation then it should find the data related to this version of the test script and not the data relative to some EUPS package setup that might be not what I intend.



class TestJointcalRunner(lsst.utils.tests.TestCase):
"""Test that JointcalRunner calls JointcalTask with appropriate arguments."""
Copy link
Member

Choose a reason for hiding this comment

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

This test class is sufficiently different to most others we have that it would be nice if there were a couple of sentences here that gave an overview of what was being done.

tracts : `list` [`int`]
List of tracts to build DataRefs for.
"""
configfile = os.path.join(lsst.utils.getPackageDir('jointcal'), 'tests/config/config.py')
Copy link
Member

Choose a reason for hiding this comment

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

Change to be relative from __file__ directory if data_dir is changing.

input_dir = os.path.join(self.data_dir, 'cfht_minimal')
# the calling method is one step back on the stack: use it to specify the output repo.
caller = inspect.stack()[1].function
output_dir = os.path.join('.test', self.__class__.__name__, caller)
Copy link
Member

Choose a reason for hiding this comment

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

Are you doing these shenanigans to aid debugging the test? Why .test/? Why not a temp directory? Is a directory actually created or is that mocked too? Can you be more explicit in your description that you want to name this directory after the test method that is being executed rather than saying "the calling method"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point: I copied this from the other jointcal tests where not having them auto-deleted (i.e. tempfile) has been very useful. In this case, tempfile is definitely appropriate.

@parejkoj
Copy link
Collaborator Author

I've pushed some comments: do they help clarify what is going on?

Add test that mocks Butler and JointcalTask to allow testing calling
JointcalRunner with different numbers of tracts specified.
@parejkoj parejkoj merged commit fa71e81 into master Mar 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants