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

correct create_personality function params to reflect usage #375

Merged
merged 3 commits into from
Dec 15, 2022

Conversation

bgerrity
Copy link
Contributor

@bgerrity bgerrity commented Dec 13, 2022

The names of the positions args used in the docs don't reflect usage; this leads to a TypeError. This change address that issue.

  File ".../gateway#link-tree/kernel_gateway/gatewayapp.py", line 447, in init_configurables
    self.personality = func(parent=self, log=self.log)
TypeError: create_personality() got an unexpected keyword argument 'log'

@bgerrity
Copy link
Contributor Author

Broken tests appear unrelated. Local build of docs succeeds.

@@ -31,7 +31,7 @@ class TemplatePersonality(LoggingConfigurable):
been specified."""
pass

def create_personality(self, parent):
def create_personality(parent, log):
Copy link
Member

Choose a reason for hiding this comment

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

Good catch!

Should the signature be: def create_personality(*args, **kwargs): and we document two required kwargs are: parent and log? This will then fit the existing declarations that reside for the websocket and http personalities while allowing for other parameters to be added in the future.

Copy link
Contributor Author

@bgerrity bgerrity Dec 14, 2022

Choose a reason for hiding this comment

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

I'm unsure about the usage of *args, **kwargs here or in the existing declarations: Based on init_configurables, I'm not I'm not seeing how any additional args could be passed to create_personality via configuration.

Copy link
Member

Choose a reason for hiding this comment

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

In the future, we may find the need to convey other information to a "personality", at which time we'd add a parameter (e.g., foo=bar) in init_configurables. Personalities that don't know about the parameter could still be called (and ignore it), while those that know what foo is for would use it via kwargs["foo"], for example.

This, coupled with the idea that signatures for "custom personalities" should match that of the two existing personalities, leads me to argue for using *args, **kwargs due to precedent.

One of the things that makes this confusing is the lack of initializers with "Configurable" classes - on which most of Jupyter is based. Both parent and log are "well-known" parameters within the LoggingConfigurable class hierarchy. (Not sure if this helps or not.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense to use that for convention and extensibility.

Copy link
Member

@kevin-bates kevin-bates left a comment

Choose a reason for hiding this comment

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

LGTM - sorry about the CI. This project needs substantial maintenance!

@kevin-bates kevin-bates merged commit ece7cbe into jupyter-server:master Dec 15, 2022
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