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

Expose a public property to sort extensions deterministically. #522

Merged
merged 1 commit into from
May 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions jupyter_server/extension/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,11 @@ def _config_manager_changed(self, change):
"""
)

@property
def sorted_extensions(self):
"""Returns an extensions dictionary, sorted alphabetically."""
return dict(sorted(self.extensions.items()))

# The `_linked_extensions` attribute tracks when each extension
# has been successfully linked to a ServerApp. This helps prevent
# extensions from being re-linked recursively unintentionally if another
Expand Down Expand Up @@ -350,7 +355,7 @@ def link_all_extensions(self, serverapp):
"""
# Sort the extension names to enforce deterministic linking
# order.
for name in sorted(self.extensions.keys()):
for name in self.sorted_extensions.keys():
self.link_extension(name, serverapp)

def load_all_extensions(self, serverapp):
Expand All @@ -359,5 +364,5 @@ def load_all_extensions(self, serverapp):
"""
# Sort the extension names to enforce deterministic loading
# order.
for name in sorted(self.extensions.keys()):
for name in self.sorted_extensions.keys():
self.load_extension(name, serverapp)