Skip to content

Conversation

@aragilar
Copy link
Contributor

This moves from the old priority system, which does not work, to the proposed system in astropy/astropy#11214. This would close #171 and #584.

This lacks direct tests, as monkeypatching the registry will probably hide problems, but I'm open to other ideas for explicitly testing for this.


def decorator(func):
io_registry.register_reader(label, dtype, func)
if _astropy_has_priorities():
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this check really necessary? If a user-defined reader/writer has no priority, seems we can just default to the lowest priority instead of resorting to reflection?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Older versions of io_registry.register_reader won't accept the additional argument, so if we don't do this check, we'll get exceptions when trying to add a priority. Once all supported versions of astropy accept priorities, we can drop the check.

@nmearl
Copy link
Contributor

nmearl commented Feb 6, 2021

@aragilar it'd be great to also have a simple loader priority test.

@nmearl nmearl mentioned this pull request Feb 23, 2021
Base automatically changed from master to main March 22, 2021 15:52
@aragilar aragilar force-pushed the add_new_astropy_priority_support branch from 24308bc to 5885ed9 Compare June 15, 2021 07:06
@aragilar
Copy link
Contributor Author

I've added a test for the priorities, which should would for both astropy versions with and without priority support. Not sure if you want to wait until 4.3 comes out before merging this or not.

@aragilar aragilar force-pushed the add_new_astropy_priority_support branch from 562aa4c to 2ff82ff Compare July 28, 2021 01:55
@aragilar
Copy link
Contributor Author

I've rebased this on top of main so that the fixes in #833 are included (so everything passes). Now that 4.3 is out, did we want to have another look at this?

Copy link
Contributor

@nmearl nmearl 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. Thanks @aragilar!

@nmearl nmearl merged commit dca5e7c into astropy:main Jul 29, 2021
@aragilar aragilar deleted the add_new_astropy_priority_support branch July 30, 2021 03:21
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.

Data loaders need prioritization to resolve multiple matches

2 participants