-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Add option to override host in displayed url #3668
Conversation
We have properties @minrk Do you remember why we have two separate URL options? I think |
Maybe this should change |
I think there probably wants to be a property involved, because something has to add the generated token to the bit you can configure. We use URLs for:
Those are all the use cases I can think of at the moment, but there may be others. |
@takluyver, regarding the different I am not too clear on the inner workings of More generally, my concern is about using @minrk, regarding the URL vs host terminology: Agreed! I initially kept the name proposed in #3605 for consistency, but I think it would be better to rename it. Just waiting for the discussion to converge on what to do to rename it accordingly. |
@takluyver good summary. In that case, I think In that case, this PR roughly as-is with |
notebook/notebookapp.py
Outdated
if self.ip in ('', '0.0.0.0'): | ||
ip = socket.gethostname() | ||
if self.connect_host: | ||
url = self.connect_host + '/' |
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.
Probably don't want to add + '/'
here, instead leave connect_url
untouched.
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.
Should connect_host
be renamed to custom_connect_url
or custom_display_url
. I'm a bit confused by the naming. Or possibly public_url
or public_display_url
.
More generally, my concern is about using jupyter-notebook as a proxied service (in a docker container, behind a proxy etc.), and needing both a publicly accessible URL for the users, and an internal URL for administering.
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.
Renamed
@minrk : regarding the trailing '/', i changed things to append it if it is missing. I think it is the "nicest" approach, but tell me if you have reserves on this.
notebook/notebookapp.py
Outdated
@@ -548,6 +548,7 @@ def start(self): | |||
'notebook-dir': 'NotebookApp.notebook_dir', | |||
'browser': 'NotebookApp.browser', | |||
'pylab': 'NotebookApp.pylab', | |||
'connect-host': 'NotebookApp.connect_host', |
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.
I don't think this is an option that warrants a CLI alias.
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.
Removed
You mean replace |
Yeah, I mean that the URL that should be used to connect should be overrideable by the user. That is, the URL written to The display URL for humans should use the connect URL, and can be a property adding things like the token. |
@minrk Sorry if I have misunderstood your proposal, what I got is that you suggest the option to not just override the return of It seems to me that it would break the functioning of commands such as The use case I have in mind is the following:
Its not clear for me if there is a way to make this work with your proposal without breaking the second point (or even if it is a non-issue and that I missed something when testing it locally) . Any thought ? |
I guess the question is:
1 would allow things like From your use cases, I think I genuinely don't know the right answer for this. Overriding display_url is certainly the least disruptive since it can't break anything, but overriding connect_url enables solving the same "How should things connect to me" problem in multiple places, not just the logs. I'm genuinely not sure what the right answer is. Another option is to add a separate 'remote_url' for connections from 'remote' hosts (e.g. the host system in the docker case), and store and display this alongside connection_url, essentially baking in the fact that there can never be only one answer to the URL question when running in containers. |
Since apparently there is two separate use cases that need different ways to be solved, I wonder if the most straightforward solution wouldn't be to add two separation options. I am not fond of having lots of small options, but in this case it seems that there is a variety of current and future use cases that could warrant it... |
@minrk What is needed for this to be completed? |
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.
The naming here is a bit confusing to me. Perhaps start with improving the docstring to be more explicit about why and when this would be used as well as what changes when using it.
notebook/notebookapp.py
Outdated
help=_("""Custom host to show in displayed URL. | ||
|
||
Replace actual host, including protocol, address, port and base URL, | ||
with the given value when displaying URL to the users. Do not change |
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.
We probably should clarify this docstring a bit. As it reads now, my understanding is that the connect_host would be displayed to the user, but the notebook would use the actual underlying connection URL.
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.
Funnily I had a very similar docstring amending in store :) I merged the two. Tell me if it seems clearer.
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.
Updated. tell me if it's still not clear enough (your understanding was correc btw 😉)
notebook/notebookapp.py
Outdated
if self.ip in ('', '0.0.0.0'): | ||
ip = socket.gethostname() | ||
if self.connect_host: | ||
url = self.connect_host + '/' |
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.
Should connect_host
be renamed to custom_connect_url
or custom_display_url
. I'm a bit confused by the naming. Or possibly public_url
or public_display_url
.
More generally, my concern is about using jupyter-notebook as a proxied service (in a docker container, behind a proxy etc.), and needing both a publicly accessible URL for the users, and an internal URL for administering.
@tomjorquera, thanks for the PR. Adding this to the docstring would be helpful:
|
Should this be pushed out to 5.7 release? |
I'd like to get it in 5.6 if practical - we have had a few bug reports since 5.5. I suggest that for now, we leave the two separate URL properties in existence, and focus on making That means that for the time being, we're saying that |
9e147dc
to
c9cc5cf
Compare
Updated the PR to clean things up regarding naming and docstring. So currently it only add the option to override the display URL and not the actual URL. For what I understand of the code, adding a second option to override the actual URL seems straightforward enough, so I think it can be added to the PR should it be the way to go... |
c9cc5cf
to
272d886
Compare
This commit introduces a new alias `custom_display_url` to override the URL info displayed at launch with a custom string. It is intended to be used when the app is run in an environment where the url to display to the users is not detectable reliably (proxified or containerized setups for example).
272d886
to
24e39d3
Compare
(also rebased on top of current master, and updated commit description) |
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.
This looks good to me. Thanks @tomjorquera for the improvements.
@tomjorquera thanks! |
This commit introduces a new alias
connect-host
to override the hostinfo displayed at launch with a custom string.
It is intended to be used when the app is run in an environment where
the url to display to the users is not detectable reliably (proxified or
containerized setups for example).
Closes #3605