-
Notifications
You must be signed in to change notification settings - Fork 506
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
Custom page config hook #1495
Custom page config hook #1495
Conversation
I think a more generic solution is to allow users to modify the page_config object by a hook function. We have this mechanism for the prelaunch hook (https://voila.readthedocs.io/en/stable/customize.html#accessing-the-tornado-request-prelaunch-hook) |
for more information, see https://pre-commit.ci
…to custom-labextension
@trungleduc what do you think about this implementation? |
while working on this, I have a question, why not use the kernel path to set the labextensions path? |
I'm thinking about a post-processing function that receives the current page_config dict and then returns a customized one. You can add more arguments to this hook function if needed. |
I don't get the idea, what would be the difference? What I'm doing to set the hooks is something like: # voila.py
from voila.app import Voila
def get_page_config_hook(....)
Voila.get_page_config_hook = get_page_config_hook I'm mutating the Voila class and setting the hook, is that the way? |
It will be easier for someone who just needs a small change in the
https://voila.readthedocs.io/en/stable/customize.html#adding-the-hook-function-to-voila |
I've created this post-processing function, does it look better to you? |
the |
it's correct |
Please rebase this branch to get the CI fix from #1497 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
is there a reason for that? one would expect the hooks to work no matter which server is used, dont you think? |
could you elaborate more on your setup? |
We have a platform that allows users to run custom AWS instances, each of this instances start a jupyter server that we use to launch jupyter and render voila apps... |
In this case, you should use the configuration file ( |
but the |
yes, It's voila/voila/server_extension.py Line 49 in f1722f4
|
Thanks! It looks neat now. Could you update the documentation about this feature? In the same section as the pre-launch hook. |
Co-authored-by: Duc Trung Le <[email protected]>
done! in 3f2ce38 I also added the page_config and prelaunch hooks to be used by the |
e6d0c78
to
7dfaa05
Compare
@dfguerrerom I moved the hooks to |
1faa3d7
to
47f7499
Compare
awesome @trungleduc ! Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!!
References
#1494
Code changes
I have added a new query param to set a customlabextensions_url
, this url has to be used when is provided by the user.I have created a draft of my own server to serve the custom lab extensions and it works as expected.I'm not sure what is the best way to deal with thelabextensions_path
and how to use the ones that are served by the tornado server, so that' why I came doing a request to the server.Any suggestion?
VoilaConfiguration
:Voila.prelaunch_hook
toVoilaConfiguration.prelaunch_hook
, this will makeprelaunch_hook
work with the server extension.Voila.prelaunch_hook
User-facing changes
Users will have the opportunity to set their custom config_page settings
Backwards-incompatible changes
None