-
Notifications
You must be signed in to change notification settings - Fork 567
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
Env variable for extra_template_basedirs #2026
Comments
This commit add the following three items. - Updates the method `_default_extra_template_basedirs` in the module `templateexporter.py` to search for a new environment variable called `NBCONVERT_EXTRA_TEMPLATE_BASEDIRS`. This environment variable will be added to the basedirs list if it is found, and it exists. - Updates the tests to ensure if the new environment variable exists then it is included in the `TemplateExporter.template_paths`. - Adds a context manager method that modifies the `os.environ` dictionary. Closes jupyter#2026
I'd like to understand this request a bit more instead of providing a band aid for a single option. Do you have a way of creating With this you should be able to hook into any logics you want without waiting for a patch/release.
Or maybe the software you use explicitly as nbconvert to not read its config, and hence the need for a patch. This does not means we cannot add the option regardless, but using the default config capabilities should allow you to modify any config option instead of creating and add-hoc version every time. If there is a global reason to use ENV variable instead of doing on a per-use-case, we could imaging having a mapping from env variable to configuration option, say That would make sens I think, but you also should be able to achieve it now with:
Allows me to set |
Thanks for the thoughtful considerations @Carreau. @govinda18 can chime in on their use case, but I can think of one where environment variables would be useful. If you have an automated deploy scenario for clients, and want all of them to use a centralized extra nbconvert templates directory that you have custom artifacts in, then I see two options available:
I suspect that (since it is easy to add/remove environment variables for newly create clients) having nbconvert read environment variables compared to updating client preferences in a python file is the easiest change from a devops perspective. This is of course is just a guess. |
Yes, this is my guess as well, but if that's the case then likely the need is likely not limited to nbconvert, and it might be worth it to patch traitlets to load from env by default in the same way that we have a config file loader and and cli loader ? |
@govinda18 I wanted to know if you had a chance to look at my suggestions and clarify your use case. |
#2075 might help |
Hi team,
I want to be able to set extra_template_basedirs via some env variable. I am using in an internal infrastructure that needs this and some external library seems to use PythonExporter to convert a notebook into python.
Would be helpful to set this globally so this gets automatically picked up.
The text was updated successfully, but these errors were encountered: