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 get_export_names to skip configuration check #1471

Merged
merged 2 commits into from
Apr 26, 2021

Conversation

rmoe
Copy link
Contributor

@rmoe rmoe commented Nov 20, 2020

This introduces an environment variable named
NBCONVERT_DISABLE_CONFIG_EXPORTERS that will cause get_export_names to
return all entrypoints instead of checking the "enabled" status of
each one.

Closes: #1439

@@ -135,6 +136,9 @@ def get_export_names(config=get_config()):
them as an nbconvert.exporter entrypoint.
"""
exporters = sorted(entrypoints.get_group_named('nbconvert.exporters'))
if os.environ.get("NBCONVERT_DISABLE_CONFIG_EXPORTERS"):
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: might be good to have a comment here so people know what this is for, i.e. bypass the (potentially slow) enable/disable check per extension if you know that you're supporting all exporters.

I also wonder if there is somewhere in the docs or config options that we could mention this environment variable otherwise people would only ever know about it if they were familiar with this code. Like maybe somewhere in here:

https://github.com/jupyter/nbconvert/blob/master/docs/source/api/exporters.rst

Though that's just auto-generated module doc.

Looking at https://nbconvert.readthedocs.io/en/latest/config_options.html#exporter-options maybe Exporter.enabled should mention this env var? Or https://nbconvert.readthedocs.io/en/latest/external_exporters.html?

A CODEOWNER might have better ideas, but I'd think mentioning it with the Exporter.enabled config option would be the most discoverable place for mentioning this variable.

Copy link
Contributor

Choose a reason for hiding this comment

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

To @mriedem 's point, https://nbconvert.readthedocs.io/en/latest/config_options.html#exporter-options would be the best place to document the environment variable action. You can add this note by editing the CLI Flags and Aliases section in autogen_config.py.

Additionally we should probably log out a quick message when we're disabling config exporters so it's visible that the flag was set when helping future nbconvert issues. Use from traitlets.log import get_logger and get_logger().info("Config exporter loading disabled, no additional exporters will be automatically included.")

@rmoe
Copy link
Contributor Author

rmoe commented Apr 8, 2021

@MSeal is there anything I need to do to help move this forward?

@MSeal
Copy link
Contributor

MSeal commented Apr 12, 2021

@rmoe Sorry I originally missed this PR (was on leave). Let me leave a comment in the implementation, but I think a quick log message and adding a note to the documentation is all that's needed.

@rmoe
Copy link
Contributor Author

rmoe commented Apr 12, 2021

@rmoe Sorry I originally missed this PR (was on leave). Let me leave a comment in the implementation, but I think a quick log message and adding a note to the documentation is all that's needed.

No worries, thank you for taking a look at this.

@meeseeksmachine
Copy link

This pull request has been mentioned on Jupyter Community Forum. There might be relevant details there:

https://discourse.jupyter.org/t/current-state-of-nbconvert-drop-support-for-python-3-6/8882/1

@mriedem
Copy link
Contributor

mriedem commented Apr 23, 2021

@rmoe CI should be fixed on master now if you want to rebase.

This introduces an environment variable named
NBCONVERT_DISABLE_CONFIG_EXPORTERS that will cause get_export_names to
return all entrypoints instead of checking the "enabled" status of
each one.

Closes: jupyter#1439
Copy link
Contributor

@mriedem mriedem left a comment

Choose a reason for hiding this comment

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

Code looks good. A couple of small nits inline but the test looks good and there is a mention of this in the docs now (so comments have been resolved) and CI is passing. 👍

nbconvert/exporters/tests/test_exporter.py Outdated Show resolved Hide resolved
'Exporter': {'enabled': False},
'NotebookExporter': {'enabled': True}
})
os.environ["NBCONVERT_DISABLE_CONFIG_EXPORTERS"] = "1"
Copy link
Contributor

Choose a reason for hiding this comment

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

Fun fact, you can use patch.dict to temporarily set values in os.environ, there is an example in the docs:

https://docs.python.org/3.7/library/unittest.mock.html#unittest.mock.patch.dict

Co-authored-by: Matt Riedemann <mriedem.os@gmail.com>
Copy link
Contributor

@MSeal MSeal left a comment

Choose a reason for hiding this comment

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

Thanks for getting this updated! LGTM

@MSeal
Copy link
Contributor

MSeal commented Apr 26, 2021

doc build issue is unrelated, I'll look into that before the next release.

@MSeal MSeal merged commit a365a5c into jupyter:master Apr 26, 2021
@MSeal MSeal added this to the 6.1 milestone Jun 8, 2021
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.

Performance regression from 5.6.1 to 6.0.7
4 participants