Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Afshin Taylor Darian
@afshin
when you say "session", what do you mean?
do you mean "when I launch jupyter lab from /path/one vs. when I launch jupyter lab from /path/two"?
Kristiyan Katsarov
@katsar0v
session I mean a current user working state. Use case: user goes to folder1. This state is saved in browser and user stays in this folder even after browser closed. There is folder2 in root dir, but he cannot cd directly with relative paths. If I give an absolute path, I can cd everywhere directly. Just tested and it works with absolute path, but the start of the absolute path is the home directory of jupyterlab, if jupyter lab is started in /tmp/var, if I cd in jupyter extension, / equals to /tmp/var
Everything solved, thank you for the help
Afshin Taylor Darian
@afshin
ha, i'm not quite sure i understood, but i'm glad it's resolved :smile:
Kristiyan Katsarov
@katsar0v
Thing was, that when cd-ing, man should be aware of relative/absolute paths, as the current directory state is saved in jupyter lab. I was not sure if absolute cd-ing was possible, but it worked
Afshin Taylor Darian
@afshin
gotcha, that's right, yeah
that serverRoot will only change if you restart the server in a different directory
so your absolute paths will work as long as the server is running in the same folder
Kristiyan Katsarov
@katsar0v
@afshin one question, I've seen that you cannot go outside the start directory in file browser, but you can go outside via the terminal and do pretty stupid stuff there, if I start jupyter lab in /tmp/dir1/, how can I prevent the user not to go above in terminal and file browser? (I already succeded dockerizing the whole thing for isolation, but I want to add some filesystem rules, along the file browser rules I've defined)
Afshin Taylor Darian
@afshin
A terminal session is exactly the same thing as the user who launched JupyterLab from the actual command line running commands in the system, so the only way you can restrict file system access is by changing the system permissions of the user who launches jupyter lab
Kristiyan Katsarov
@katsar0v
Okay, that makes sense, I could strengthen this with chmod, cool. Is it possible to remove the terminal for example?
Afshin Taylor Darian
@afshin
You set the page_config.json to have terminalsAvailable set to false
Kristiyan Katsarov
@katsar0v
You mean in /home/user/anaconda/share/jupyter/lab/settings ?
Afshin Taylor Darian
@afshin
Yeah, probably there. It's the settings directory that is inside the "Application directory" when you run the command jupyter lab paths, right?
create a file called page_config.json if it doesn't exist
and have the file contain:
{
    "terminalsAvailable": false
}
Kristiyan Katsarov
@katsar0v
Works, great! Thank you. Is there any documentation of all options available, or is still in beta phase?
Afshin Taylor Darian
@afshin
But this particular one isn't there. Probably should be.
Afshin Taylor Darian
@afshin
jupyterlab/jupyterlab#4831
I filed an issue to document it.
Kristiyan Katsarov
@katsar0v
Thank you. I will read further these docs
Afshin Taylor Darian
@afshin
no prob :+1:
Matthias Meschede
@MMesch

Just for reference. Here is a minimal server extension that serves documentation from it's own root folder:

from notebook.utils import url_path_join

import os
from tornado.web import StaticFileHandler


def _jupyter_server_extension_paths():
    return [{'module': 'jupyterlab_MyDoc'}]

def load_jupyter_server_extension(nb_server_app):
    """
    Called when the extension is loaded.
    Args:
        nb_server_app (NotebookApp): handle to the Notebook webserver instance.
    """
    web_app = nb_server_app.web_app
    # Prepend the base_url so that it works in a jupyterhub setting
    base_url = web_app.settings['base_url']
    doc_url = url_path_join(base_url, 'my_doc')

    doc_dir = os.path.join(os.path.dirname(__file__), 'static', 'doc', 'html')

    handlers = [(f'{doc_url}/(.*)',
                StaticFileHandler,
                {'path': doc_dir})]
    web_app.add_handlers('.*$', handlers)

it can then be opened in a widget with:

  function createDocumentation(): IFrame {
    let baseUrl = PageConfig.getBaseUrl();
    let iframe = new IFrame();
    iframe.url = baseUrl + 'my_doc/index.html';
    iframe.id = 'Mydoc';
    iframe.title.label = 'My documentation';
    iframe.title.closable = true;
    iframe.node.style.overflowY = 'auto';
    shell.addToMainArea(iframe);
    return iframe
  }
Kristiyan Katsarov
@katsar0v
Is this a server extension for jupyter notebooks or lab?
Matthias Meschede
@MMesch
not sure if that's the best way but it works well ;)
this is for jupyterlab
Afshin Taylor Darian
@afshin
nice, looks good to me
Kristiyan Katsarov
@katsar0v
oh nice, I did not even know lab has server extensions
Matthias Meschede
@MMesch
me neither until 2 hours ago
Afshin Taylor Darian
@afshin
server extensions for classic and lab work the same way. the only time it'd be different is if you imported something specifically from, say jupyterlab_launcher or something and expected the lab server to be running
so they are the same extensions that have existed all along as far as the server is concerned
labextension are the front-end extension system, which is totally different between classic and lab
but the serverextension remains the same
Kristiyan Katsarov
@katsar0v
Thanks, so the docs here http://jupyter-notebook.readthedocs.io/en/stable/extending/handlers.html are also valid for jupyter lab?
Matthias Meschede
@MMesch
@afshin it would be nice at some point to add one paragraph about this to the jupyterlab development documentation (in case I didn't miss it again ...)

Thanks, so the docs here http://jupyter-notebook.readthedocs.io/en/stable/extending/handlers.html are also valid for jupyter lab?

it could be just a link to this page ...

Afshin Taylor Darian
@afshin
yes, that is accurate. good point about documenting, i'm not sure it's explicitly made clear.
Jason Grout
@jasongrout

it would be nice at some point to add one paragraph about this to the jupyterlab

@MMesch - can you file an issue (or even better, a PR)

@/all - on account of the US holiday tomorrow, we've switched the dev meeting to after the normal Jupyter dev meeting today. The normal Jupyter dev meeting starts at 9am, and usually lasts until 9:30-9:45, so we expect the lab dev meeting to start between 9:30-10.
(all those times are in Pacific time, so that 9am start time is 1.5 hours from now)
Afshin Taylor Darian
@afshin
:+1:
Saul Shanabrook
@saulshanabrook
Great. Can you post on here when it's starting?
Jason Grout
@jasongrout
Great idea
I have some thoughts about the new services api after trying to port over the widgets extension I would like to discuss
and please add to the changelog: jupyterlab/jupyterlab#4622
especially breaking changes
and it would be great if someone could review jupyterlab/jupyterlab#4330
(@afshin, I changed some of the focusing behavior for the console in #4330 so you could open a console without activating it)