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

Fix sync index column order to match order from astropy 4.0 #215

Merged
merged 6 commits into from
Feb 10, 2021

Conversation

jeanconn
Copy link
Contributor

@jeanconn jeanconn commented Feb 9, 2021

Description

Set sync index column order to match the alphabetical order that resulted in astropy 4.0. In astropy 4.2 the column order when initializing from a list of dict is the order of keys in the first row. Since astropy 4.2 requires Python 3.7, which has dict ordered, this makes more sense than the previous behavior of just alphabetizing.

Testing

  • Passes unit tests on linux
  • [N/A] Functional testing

This showed up in unit test failures with astropy 4.2 in skare 2021.2 env on linux, so the unit tests passing are probably sufficient.

Fixes #216

@jeanconn jeanconn requested a review from taldcroft February 9, 2021 16:41
@taldcroft
Copy link
Member

Good catch on the issue. One Table API change was that when initializing from a dict, it used to alphabetize the columns, now (since ordered dicts in Py 3.7) it just uses the order from the dict. I haven't looked in our code to see if that is the source of the discrepancy.

I agree with your general approach, though I'm not sure the explicit list of columns and column order is actually necessary. My original code gets a 👎 for requiring a particular order.

@jeanconn
Copy link
Contributor Author

jeanconn commented Feb 9, 2021

👍 for having a test that caught this though!

@jeanconn
Copy link
Contributor Author

jeanconn commented Feb 9, 2021

But with regard to "though I'm not sure the explicit list of columns and column order is actually necessary.", I figured the same. Not being as familiar with this codebase, I wasn't sure if there might be some other piece of code not unit tested that had an implicit requirement... or if changing column order in the real (not test) cheta sync archive could cause processing hiccups.

@jeanconn
Copy link
Contributor Author

jeanconn commented Feb 9, 2021

Well, new index order could cause processing hiccups or it could just break old clients (laptops or versions run from ska3-matlab)... right?

@taldcroft taldcroft changed the title Set sync index column order explicitly Fix sync index column order to match order from astropy 4.0 Feb 10, 2021
@taldcroft
Copy link
Member

@jeanconn - I added some commits and this should be good to go now. I'm approving, and you should have a fresh look as well.

@taldcroft
Copy link
Member

If this were an astropy PR I might think about squashing the commits down to 1, but whatever.

@@ -476,13 +476,14 @@ def update_full_h5_files(dat, logger, msid_files, msids, opt):
def get_full_data_sets(ft, index_tbl, logger, opt):
# Iterate over sync files that contain new data
dats = []
for date_id, filetime0, filetime1, row0, row1 in index_tbl:
for row in index_tbl:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

And sure 'row' is fine. I probably overthought it... I avoided 'row' as the var just because the lines of the index table defined row spaces.

@@ -196,9 +196,9 @@ def get_row_from_archfiles(archfiles):
# date like 2019-02-20T2109z, human-readable and Windows-friendly (no :) for a unique
# identifier for this set of updates.
date_id = get_date_id(DateTime(archfiles[0]['filetime']).fits)
row = {'filetime0': archfiles[0]['filetime'],
row = {'date_id': date_id,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

And sure. Removing the explicit list in file_defs and replacing with this strategy to get the columns in the right order seems fine. You have a better handle on astropy development to know which would be more stable in the long-term.
And we presently don't see a driver for keeping the column order in file_defs for reference (which you might want if you thought this could vary based on environment).

Copy link
Member

Choose a reason for hiding this comment

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

Our code should always be written to be tolerant of changes to column order or potentially new columns. My original implementation was the root problem, nothing more.

In astropy we strive for API stability, but sometimes allow cleaning up legacy design mistakes (or in these cases, designs that became mistakes due to language changes).

@jeanconn jeanconn merged commit 7e86bbe into master Feb 10, 2021
@jeanconn jeanconn deleted the index_col_order branch February 10, 2021 16:45
This was referenced Feb 26, 2021
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.

Sync tests fail in ska3-flight 2021.2rc4 on linux
2 participants