urls.rst 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. .. _urls:
  2. JupyterLab URLs
  3. ---------------
  4. Like the classic notebook, JupyterLab provides a way for users to copy URLs that
  5. open a specific notebook or file. Additionally, JupyterLab URLs are an advanced
  6. part of the user interface that allows for managing workspaces. These two
  7. functions -- file paths and workspaces -- can be :ref:`combined in URLs that open a
  8. specific file in a specific workspace <url-combine>`.
  9. .. _url-tree:
  10. File Navigation with ``/tree``
  11. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  12. JupyterLab's file navigation URLs adopts
  13. the nomenclature of the classic notebook; these URLs are ``/tree`` URLs:
  14. .. code-block:: none
  15. http(s)://<server:port>/<lab-location>/lab/tree/path/to/notebook.ipynb
  16. Entering this URL will open the notebook in JupyterLab in
  17. :ref:`single-document mode <tabs>`.
  18. .. _url-workspaces-ui:
  19. Managing Workspaces (UI)
  20. ~~~~~~~~~~~~~~~~~~~~~~~~
  21. JupyterLab sessions always reside in a workspace. Workspaces contain the state
  22. of JupyterLab: the files that are currently open, the layout of the application
  23. areas and tabs, etc. When the page is refreshed, the workspace is restored.
  24. The default workspace does not have a name and resides at the primary ``/lab``
  25. URL:
  26. .. code-block:: none
  27. http(s)://<server:port>/<lab-location>/lab
  28. All other workspaces have a name that is part of the URL:
  29. .. code-block:: none
  30. http(s)://<server:port>/<lab-location>/lab/workspaces/foo
  31. Workspaces save their state on the server and can be shared between
  32. multiple users (or browsers) as long as they have access to the same server.
  33. A workspace should only be open in a single browser tab at a time. If JupyterLab
  34. detects that a workspace is being opened multiple times simultaneously, it will
  35. prompt for a new workspace name. Opening a document in two different browser
  36. tabs simultaneously is also not supported.
  37. .. _url-clone:
  38. Cloning Workspaces
  39. ~~~~~~~~~~~~~~~~~~
  40. You can copy the contents of a workspace into another workspace with the ``clone`` url parameter.
  41. To copy the contents of the workspace ``foo`` into the workspace ``bar``:
  42. .. code-block:: none
  43. http(s)://<server:port>/<lab-location>/lab/workspaces/bar?clone=foo
  44. To copy the contents of the default workspace into the workspace ``foo``:
  45. .. code-block:: none
  46. http(s)://<server:port>/<lab-location>/lab/workspaces/foo?clone
  47. To copy the contents of the workspace ``foo`` into the default workspace:
  48. .. code-block:: none
  49. http(s)://<server:port>/<lab-location>/lab?clone=foo
  50. .. _url-reset:
  51. Resetting a Workspace
  52. ~~~~~~~~~~~~~~~~~~~~~
  53. Use the ``reset`` url parameter to clear a workspace of its contents.
  54. To reset the contents of the workspace ``foo``:
  55. .. code-block:: none
  56. http(s)://<server:port>/<lab-location>/lab/workspaces/foo?reset
  57. To reset the contents of the default workspace:
  58. .. code-block:: none
  59. http(s)://<server:port>/<lab-location>/lab/workspaces/lab?reset
  60. .. _url-combine:
  61. Combining URL Functions
  62. ~~~~~~~~~~~~~~~~~~~~~~~
  63. These URL functions can be used separately, as above, or in combination.
  64. To reset the workspace ``foo`` and load a specific notebook afterward:
  65. .. code-block:: none
  66. http(s)://<server:port>/<lab-location>/lab/workspaces/foo/tree/path/to/notebook.ipynb?reset
  67. To clone the contents of the workspace ``bar`` into the workspace ``foo`` and
  68. load a notebook afterward:
  69. .. code-block:: none
  70. http(s)://<server:port>/<lab-location>/lab/workspaces/foo/tree/path/to/notebook.ipynb?clone=bar
  71. To reset the contents of the default workspace and load a notebook:
  72. .. code-block:: none
  73. http(s)://<server:port>/<lab-location>/lab/tree/path/to/notebook.ipynb?reset
  74. .. _url-workspaces-cli:
  75. Managing Workspaces (CLI)
  76. ~~~~~~~~~~~~~~~~~~~~~~~~~
  77. JupyterLab provides a command-line interface for workspace ``import`` and
  78. ``export``:
  79. .. code-block:: bash
  80. $ # Exports the default JupyterLab workspace
  81. $ jupyter lab workspaces export
  82. {"data": {}, "metadata": {"id": "/lab"}}
  83. $
  84. $ # Exports the workspaces named `foo`
  85. $ jupyter lab workspaces export foo
  86. {"data": {}, "metadata": {"id": "/lab/workspaces/foo"}}
  87. $
  88. $ # Exports the workspace named `foo` into a file called `file_name.json`
  89. $ jupyter lab workspaces export foo > file_name.json
  90. $
  91. $ # Imports the workspace file `file_name.json`.
  92. $ jupyter lab workspaces import file_name.json
  93. Saved workspace: <workspaces-directory>/labworkspacesfoo-54d5.jupyterlab-workspace
  94. The ``export`` functionality is as friendly as possible: if a workspace does not
  95. exist, it will still generate an empty workspace for export.
  96. The ``import`` functionality validates the structure of the workspace file and
  97. validates the ``id`` field in the workspace ``metadata`` to make sure its URL is
  98. compatible with either the ``workspaces_url`` configuration or the ``page_url``
  99. configuration to verify that it is a correctly named workspace or it is the
  100. default workspace.