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-13524: Add unit tests for ingestion #24

Merged
merged 3 commits into from Mar 26, 2018
Merged

Conversation

kfindeisen
Copy link
Member

This PR adds minimalist tests of ingestion. A couple of minor bugs are fixed, but the rest are deferred to future tickets.

There is no test for attempts to ingest nonexistent files, as the default *IngestionTask behavior (log and ignore) is difficult to test.

Copy link
Contributor

@mrawls mrawls 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 great. The only thing I might add is a test that drills into the registries and makes sure they are properly populated.

Returns
-------
butler : `lsst.daf.persistence.Butler`
A butler that should all be capable of finding ingested science data.
Copy link
Contributor

Choose a reason for hiding this comment

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

Here and in the next one, "A butler that should all be capable of finding" is oddly worded. Do you mean "should be capable of finding all ingested [...] data" ?

'mapperArgs': {'calibRoot': self._calibRepo}})

def tearDown(self):
shutil.rmtree(self._repo, ignore_errors=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

This does make sense here but I'm just laughing to myself about ignore_errors as an argument 😆

calibFile) for calibFile in
[os.path.join('fci.fits'),
os.path.join('zci.fits')]
]
Copy link
Contributor

Choose a reason for hiding this comment

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

This definition of files is difficult to make sense of over several lines. Consider defining testDataDir first and then grabbing the two files.

@unittest.skip("Dataset enumeration requires specific data keys for date, filter, etc., see DM-12762")
def testNoFileIngest(self):
"""Test that attempts to ingest nothing do nothing.
"""
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 not convinced that loudly crashing is a bad thing if a user tries to ingest nothing, because I can't think of a use case where I would intentionally want to ingest nothing. Am I missing something?

Copy link
Member Author

Choose a reason for hiding this comment

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

I can't think of a specific use case either, but failing over something like this is very unusual/surprising behavior. For example, if you try to iterate over an empty list, you expect the loop to simply do nothing instead of punishing you for not writing special-case code that would have amounted to the same thing.

Also, having a low-level function exit because of invalid inputs is extremely bad practice. If we want to ban empty file lists, the function should raise an exception so that the program can decide whether or not an exit is warranted (and have a chance to clean up properly either way).

The previous implementation required a highly specific yet
undocumented directory structure. The new version is more flexible.
The tests test basic "normal operation" functionality. Testing no-ops
is not possible until we fix a repository bug, and testing invalid
files is impossible given Stack error-handling conventions.
@kfindeisen kfindeisen merged commit e767f85 into master Mar 26, 2018
@kfindeisen kfindeisen deleted the tickets/DM-13524 branch November 30, 2018 22:04
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