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-30497: Bug: DiaSource table cannot find Ixx column #115
Conversation
Where can we put a consistency check for these values against those in |
Sure, it could work there. As far as I know there is supposed to eventually be a central place to test against for schemas derived from the DPDD. Colin would be the best person to ask about that I would guess. |
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.
Tried it and got an error on ixxPsf
, because it's ixxPSF
. I strongly agree with John's comment that we need a consistency check 😱
Why can't we test it here in this package? |
@@ -295,6 +296,10 @@ def setUp(self): | |||
self.apdb.storeDiaObjects(self.diaObjects, | |||
self.dateTime) | |||
|
|||
# These columns intentionally appear in DiaSource.yaml, | |||
# but not in the APDB schema | |||
self.ignoreColumns = ["filterName", "bboxSize", "isDipole"] |
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.
They are specified in the schema-extra file in ap_association.
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.
Thanks, I figured there was someplace these not-DPDD-yet-important columns lived.
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.
Actually, I see filterName
and isDipole
in there, but where does bboxSize
come from?
@@ -390,6 +395,25 @@ def testGetPixelRanges(self): | |||
self.assertEqual(normPix, testPix) | |||
self.assertEqual(flipPix, testPix) | |||
|
|||
def test_apdbSchema(self): |
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.
This only tests if the default schema for adpb and the functors run by default match. Also, it is safe to have extra columns in the apdb schema not filled by the DiaSource functor file. The main testing I've been doing to make sure things work has been running ap_verify as an integration test. That only just failed, as we've discovered, as sqlite is not case sensitive in it's column names but Postgres is. We can leave these here for now, but I will point out that it does not protect against mismatches in the schema files.
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.
How does this not protect against mismatches in the schema files? This test ensures that everything is case-consistent as well.
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.
The schemas can be set at run time. This only tests for the default ones. It doesn't even pull in all columns that are currently being used and written to the apdb.
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 think testing default schema agreement is better than not testing at all, but that's a good point about the limitation. I agree with John that it would be better to test against an actually instantiated database, but that's more than I'm willing to do for this ticket.
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.
Thanks for adding the test; I have some suggestions about reworking it.
I would prefer if this could be a test against an actually instantiated database, instead of just testing yaml file contents, but that might be too tricky to implement.
tests/test_loadDiaCatalogs.py
Outdated
@@ -295,6 +296,10 @@ def setUp(self): | |||
self.apdb.storeDiaObjects(self.diaObjects, | |||
self.dateTime) | |||
|
|||
# These columns intentionally appear in DiaSource.yaml, | |||
# but not in the APDB schema |
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.
Period at the end of sentence, please.
table_list = list(yaml.safe_load_all(yaml_stream)) | ||
for table in table_list: | ||
if table['table'] == 'DiaSource': | ||
apdbSchemaColumns = [column['name'] for column in table['columns']] |
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.
Wouldn't you then want a break
after this, since there should only be one DiaSource
table, so you no longer need to loop over the table_list?
tests/test_loadDiaCatalogs.py
Outdated
diaSourceFunctor = yaml.safe_load_all(yaml_stream) | ||
for functor in diaSourceFunctor: | ||
diaSourceColumns = list(functor['funcs'].keys()) | ||
for column in diaSourceColumns: |
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.
Instead of this loop, could you do self.assertEqual(set(diaSourceColumns), set(apdbSchemaColumns))
, or maybe self.assertLess(set(diaSourceColumns), set(apdbSchemaColumns))
since I think the one is a proper subset of the other?
@@ -390,6 +395,25 @@ def testGetPixelRanges(self): | |||
self.assertEqual(normPix, testPix) | |||
self.assertEqual(flipPix, testPix) | |||
|
|||
def test_apdbSchema(self): |
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.
How does this not protect against mismatches in the schema files? This test ensures that everything is case-consistent as well.
tests/test_loadDiaCatalogs.py
Outdated
for functor in diaSourceFunctor: | ||
diaSourceColumns = [column for column in list(functor['funcs'].keys()) | ||
if column not in self.ignoreColumns] | ||
self.assertLess(set(diaSourceColumns), set(apdbSchemaColumns)) |
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.
This assert should go outside the for
loop: you want to build up the list of column names from the DiaSource.yaml
file, and then check against that whole list.
No description provided.