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

Allow installed extensions to be configured with AsdfConfig #847

Merged

Conversation

eslavich
Copy link
Contributor

@eslavich eslavich commented Aug 3, 2020

This PR refactors the existing extension code to make the new API easier to implement. Changes include:

  • Move extension loading from _DefaultExtensions to the new asdf.entry_points module
  • Move list of registered extensions from _DefaultExtensions to AsdfConfig
  • Remove most of the code from _DefaultExtensions so that it becomes a thin interface around AsdfConfig
  • Add methods for adding and removing registered extensions at runtime
  • Add wrapper that allows extensions to carry around their own metadata

@eslavich eslavich added this to the 2.8.0 milestone Aug 3, 2020
self._extension_list = AsdfExtensionList(self.extensions)

return self._extension_list
return AsdfExtensionList(self.extensions)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is exceedingly too clever for me. This class(?) property uses self.extensions, but the class has no init nor inherits from another class, and yet has that attribute? I need to catch up on my meta meta classes.

Copy link
Contributor Author

@eslavich eslavich Aug 4, 2020

Choose a reason for hiding this comment

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

The extensions property is still there! It's just obscured on GitHub by the ugly diff.

@property
def extensions(self):
from ..config import get_config
return [e for e in get_config().extensions if e.legacy]

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed. Sorry...

@@ -214,8 +247,10 @@ def _check_extensions(self, tree, strict=False):
return

for extension in tree['history']['extensions']:
installed = next((e for e in self.extensions if e.class_name == extension.extension_class), None)
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess I would prefer a bit more verbose construction than using next() to provide the default None. But that's just me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will be changing in a future PR anyway, since the condition gets too complex for one line. I'll leave it alone for the moment.

Copy link
Contributor

@perrygreenfield perrygreenfield left a comment

Choose a reason for hiding this comment

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

The only problem I saw was my own lying eyes...

@eslavich eslavich merged commit 00908dd into asdf-format:master Aug 4, 2020
@eslavich eslavich deleted the eslavich-add-extension-config branch August 4, 2020 23:08
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.

2 participants