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

Disable nbextension in first location found #2725

Closed
wants to merge 5 commits into from

Conversation

takluyver
Copy link
Member

@takluyver takluyver commented Aug 4, 2017

Alternative to #2724.

This implements option 1 from Min's comment: find the first location where the config enables the extension, and remove it. This makes it the default, and simplifies the options available, on the grounds that 99% of the time, when you're asking to disable something, you don't care which bit of config is enabling it.

It adds some code because it bypasses the inheritance tree of applications that has been built. Looking at this code, I think we've over-abstracted the actual operations a bit, which makes it less clear what's going on. I'd like to flatten it a bit, but not in this PR.

@minrk
Copy link
Member

minrk commented Aug 4, 2017

I like this better than #2724. It's what I would expect from disable. I would also expect uninstall to do the same.

}}, "Disable an extension from a Python package name")
}
flags['python'] = flags['py']
aliases = {'section': 'ToggleNBExtensionApp.section'}
Copy link
Member

Choose a reason for hiding this comment

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

This should still inherit the --system, --user, --sys-prefix flags, etc. from ToggleNBExtensionApp. There's still a valid use case:

A system-wide installation enabled an extension, but you want to disable it in your own configuration. Passing --user in this case (which should store False, not pop config) makes sense as an override of the system defaults.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've added the --user and --sys.prefix flags. I don't think --system is necessary, since there's nothing for system config to override.

@minrk
Copy link
Member

minrk commented Aug 4, 2017

I was in the process of writing a comment that it would be nice to not lose the inheritance then saw that you had just updated it to do exactly what I was going to ask for :)

@minrk
Copy link
Member

minrk commented Aug 4, 2017

Oops. I was confused - the diff just moved because you added the uninstall application.

Restoring comment: It would probably be nice if we can keep the extensionapp inheritance, if only for preserving the consistency of the flags/aliases without having to duplicate it all. All of the enable flags should also be on disable (--system is missing, as is --debug).

except ArgumentConflict as e:
sys.exit(str(e))
else:
self.find_uninstall_extension()
Copy link
Member

Choose a reason for hiding this comment

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

👍

help="""Which config section to disable the extension in."""
)

def start(self):
Copy link
Member

Choose a reason for hiding this comment

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

Could we get away with only overriding start, instead of losing the ToggleNBExtensionApp inheritance?

@takluyver
Copy link
Member Author

I decided there wasn't enough significant code in common between the enable & disable apps to keep a base class, so I folded the remainder of ToggleNBExtensionApp into EnableNBExtensionApp and simplified it.

@gnestor
Copy link
Contributor

gnestor commented Aug 4, 2017

I'd like to publish a release candidate by EOD so that people can start testing 5.1 this weekend and then try to officially release on Tuesday. Does this PR close #2149 or is it a part of the solution? From my understanding, with or without an --all flag, we want to be able to disable an extension from all prefixes with a single command. Does this PR get us there? How much more would it take to get this for serverextensions, too? And do we also want the same for uninstall or does uninstall not work the same?

@takluyver
Copy link
Member Author

It doesn't add a --all flag, but I think it's a different approach to meeting the needs described in #2149: you can disable or uninstall an extension without working out where it's installed/enabled.

I'd consider saving the --all flag to remove/disable all extensions (rather than removing/disabling one in all locations).

It shouldn't be much more work to do it for serverextensions, but there's not much of the day left here now. I'll have a go after dinner, but I might not get it done today.

@gnestor
Copy link
Contributor

gnestor commented Aug 4, 2017

Ok, no worries. Let's shoot for a rc tomorrow!

@takluyver
Copy link
Member Author

I think the find-and-remove strategy makes sense for uninstall, but on reflection, I wonder if the default action for disable should be to set it to False in the user config directory, overriding system or installed config.

In the scenario Min described - extension enabled systemwide, user wants to disable it - running jupyter nbextension disable foo is the obvious thing to try, but as this PR stands, it would give you a permission error as it tried to remove the systemwide config.

@takluyver
Copy link
Member Author

In fact, what I'm suggesting is what jupyter nbextension disable already does before this PR. @minrk how would you feel about me reverting the changes to enable/disable, and just changing uninstall for now?

@minrk
Copy link
Member

minrk commented Aug 6, 2017

In fact, what I'm suggesting is what jupyter nbextension disable already does before this PR. @minrk how would you feel about me reverting the changes to enable/disable, and just changing uninstall for now?

That sounds great to me, actually.

takluyver added a commit to takluyver/notebook that referenced this pull request Aug 7, 2017
@takluyver
Copy link
Member Author

#2729 does that. Closing this one.

@takluyver takluyver closed this Aug 7, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants