directories.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. Advanced Usage
  2. ==============
  3. JupyterLab manages several different locations for its data. These locations are shown by running ``jupyter lab path``:
  4. - **Application Directory**: where JupyterLab stores the main build of JupyterLab with associated data, including extensions built into JupyterLab.
  5. - **User Settings Directory**: where JupyterLab stores user-level settings for JupyterLab extensions
  6. - **Workspaces Directory**: where JupyterLab stores workspaces
  7. Additionally, JupyterLab can load dynamic federated extensions, i.e., extensions that bundle their dependencies, from the ``labextensions`` subdirectories of the Jupyter ``data`` directories in the Jupyter path hierarchy. See the locations of these ``data`` paths by running ``jupyter --path``.
  8. JupyterLab Build Process
  9. ------------------------
  10. To rebuild the app directory, run ``jupyter lab build``. By default, the
  11. ``jupyter labextension install`` command builds the application, so you
  12. typically do not need to call ``build`` directly.
  13. Building consists of:
  14. - Populating the ``staging/`` directory using template files
  15. - Handling any locally installed packages
  16. - Ensuring all installed assets are available
  17. - Bundling the assets
  18. - Copying the bundled assets to the ``static`` directory
  19. Note that building will always use the latest JavaScript packages that meet
  20. the dependency requirements of JupyterLab itself and any installed extensions.
  21. If you wish to run JupyterLab with the set of pinned requirements that was
  22. shipped with the Python package, you can launch as
  23. ``jupyter lab --core-mode``.
  24. The build process uses a specific ``yarn`` version with a default working
  25. combination of npm packages stored in a ``yarn.lock`` file shipped with
  26. JupyterLab. Those package source urls point to the default yarn registry.
  27. However, if you defined your own yarn registry in the yarn configuration, the
  28. default yarn registry will be replaced by your custom registry. If you then
  29. switch back to the default yarn registry, you will need to clean your
  30. ``staging`` folder before building:
  31. .. code:: bash
  32. jupyter lab clean
  33. jupyter lab build
  34. Disabling Rebuild Checks
  35. ^^^^^^^^^^^^^^^^^^^^^^^^
  36. JupyterLab automatically checks to see if it needs to rebuild on startup. In
  37. some cases, such as automated testing, you may wish to disable the startup
  38. rebuild checks altogether. This can be achieved through setting ``buildCheck``
  39. and ``buildAvailable`` in ``jupyter_notebook_config.json`` (or ``.py``
  40. equivalent) in any of the ``config`` locations returned by ``jupyter
  41. --paths``.
  42. .. code:: json
  43. {
  44. "LabApp": {
  45. "tornado_settings": {
  46. "page_config_data": {
  47. "buildCheck": false,
  48. "buildAvailable": false,
  49. }
  50. }
  51. }
  52. }
  53. JupyterLab Application Directory
  54. --------------------------------
  55. The application directory contains the main JupyterLab application files,
  56. including built assets, files for rebuilding JupyterLab, installed extensions
  57. and linked packages, etc.
  58. By default, the application directory is at
  59. ``<sys-prefix>/share/jupyter/lab``, where ``<sys-prefix>`` is the
  60. site-specific directory prefix of the current Python environment. You can
  61. query the current application path by running ``jupyter lab path``. The
  62. application directory can be overridden using the ``--app-dir`` command-line
  63. option in any of the JupyterLab commands, or by setting the ``JUPYTERLAB_DIR``
  64. environment variable.
  65. We recommend users not install JupyterLab in a system location on Unix-like
  66. systems, because then the application directory will be read-only. Instead,
  67. use a conda environment or ``pip install --user jupyterlab`` so the
  68. application directory is writeable by the user.
  69. This directory location and semantics do *not* follow the standard Jupyter
  70. config semantics because we need to build a single unified application, and
  71. the default config location for Jupyter is at the user level (user's home
  72. directory). By explicitly using a sys-prefix directory, we can ensure better
  73. isolation in virtual environments.
  74. The JupyterLab application directory contains the subdirectories
  75. ``extensions``, ``schemas``, ``settings``, ``staging``, ``static``, and
  76. ``themes``. In the rest of this section, we will explain each subdirectory.
  77. .. _extensions-1:
  78. extensions
  79. ^^^^^^^^^^
  80. The ``extensions`` directory has the packed tarballs for each of the
  81. installed extensions for the app. If the application directory is not
  82. the same as the ``sys-prefix`` directory, the extensions installed in
  83. the ``sys-prefix`` directory will be used in the app directory. If an
  84. extension is installed in the app directory that exists in the
  85. ``sys-prefix`` directory, it will shadow the ``sys-prefix`` version.
  86. Uninstalling an extension will first uninstall the shadowed extension,
  87. and then attempt to uninstall the ``sys-prefix`` version if called
  88. again. If the ``sys-prefix`` version cannot be uninstalled, its plugins
  89. can still be ignored using ``ignoredPackages`` metadata in ``settings``.
  90. schemas
  91. ^^^^^^^
  92. The ``schemas`` directory contains `JSON
  93. Schemas <http://json-schema.org/>`__ that describe the settings used by
  94. individual extensions. Users may edit these settings using the
  95. JupyterLab Advanced Settings Editor.
  96. settings
  97. ^^^^^^^^
  98. The ``settings`` directory may contain ``page_config.json``, ``overrides.json``, and/or
  99. ``build_config.json`` files, depending on which configurations are
  100. set on your system.
  101. .. _page_configjson:
  102. page_config.json
  103. """"""""""""""""
  104. The ``page_config.json`` data is used to provide configuration data to the
  105. application environment.
  106. The following configurations may be present in this file:
  107. 1. ``terminalsAvailable`` identifies whether a terminal (i.e. ``bash/tsch``
  108. on Mac/Linux OR ``PowerShell`` on Windows) is available to be launched
  109. via the Launcher. (This configuration was predominantly required for
  110. Windows prior to PowerShell access being enabled in Jupyter Lab.) The
  111. value for this field is a Boolean: ``true`` or ``false``.
  112. 2. ``disabledExtensions`` controls which extensions should not load at all.
  113. 3. ``deferredExtensions`` controls which extensions should not load until
  114. they are required by something, irrespective of whether they set
  115. ``autoStart`` to ``true``.
  116. The values for the ``disabledExtensions`` and ``deferredExtensions`` fields
  117. are arrays of strings. The following sequence of checks are performed
  118. against the patterns in ``disabledExtensions`` and ``deferredExtensions``.
  119. - If an identical string match occurs between a config value and a
  120. package name (e.g., ``"@jupyterlab/apputils-extension"``), then the
  121. entire package is disabled (or deferred).
  122. - If the string value is compiled as a regular expression and tests
  123. positive against a package name (e.g.,
  124. ``"disabledExtensions": ["@jupyterlab/apputils*$"]``), then the
  125. entire package is disabled (or deferred).
  126. - If an identical string match occurs between a config value and an
  127. individual plugin ID within a package (e.g.,
  128. ``"disabledExtensions": ["@jupyterlab/apputils-extension:settings"]``),
  129. then that specific plugin is disabled (or deferred).
  130. - If the string value is compiled as a regular expression and tests
  131. positive against an individual plugin ID within a package (e.g.,
  132. ``"disabledExtensions": ["-@jupyterlab/apputils-extension:set.*$"]``),
  133. then that specific plugin is disabled (or deferred).
  134. An example of a ``page_config.json`` file is:
  135. .. code:: json
  136. {
  137. "disabledExtensions": [
  138. "@jupyterlab/toc"
  139. ],
  140. "terminalsAvailable": false
  141. }
  142. .. _overridesjson:
  143. overrides.json
  144. """"""""""""""
  145. You can override default values of the extension settings by defining new
  146. default values in an ``overrides.json`` file. For example, if you would like
  147. to override the default theme to be the dark theme, an ``overrides.json`` file
  148. containing the following lines should be added in the application settings
  149. directory (by default this is the ``share/jupyter/lab/settings`` folder).
  150. .. code:: json
  151. {
  152. "@jupyterlab/apputils-extension:themes": {
  153. "theme": "JupyterLab Dark"
  154. }
  155. }
  156. .. _build_configjson:
  157. build_config.json
  158. """""""""""""""""
  159. The ``build_config.json`` file is used to track the local directories
  160. that have been installed using
  161. ``jupyter labextension install <directory>``, as well as core extensions
  162. that have been explicitly uninstalled. An example of a
  163. ``build_config.json`` file is:
  164. .. code:: json
  165. {
  166. "uninstalled_core_extensions": [
  167. "@jupyterlab/markdownwidget-extension"
  168. ],
  169. "local_extensions": {
  170. "@jupyterlab/python-tests": "/path/to/my/extension"
  171. }
  172. }
  173. staging and static
  174. ^^^^^^^^^^^^^^^^^^
  175. The ``static`` directory contains the assets that will be loaded by the
  176. JupyterLab application. The ``staging`` directory is used to create the
  177. build and then populate the ``static`` directory.
  178. Running ``jupyter lab`` will attempt to run the ``static`` assets in the
  179. application directory if they exist. You can run ``jupyter lab --core-mode``
  180. to load the core JupyterLab application from the installation directory (i.e.,
  181. the application without any extensions) instead.
  182. If JupyterLab is launched and the static assets are not present, it will
  183. display an error in the console and in the browser.
  184. themes
  185. ^^^^^^
  186. The ``themes`` directory contains assets (such as CSS and icons) for
  187. JupyterLab theme extensions.
  188. JupyterLab User Settings Directory
  189. ----------------------------------
  190. The user settings directory contains the user-level settings for Jupyter
  191. extensions.
  192. By default, the location is ``$HOME/.jupyter/lab/user-settings/``, where
  193. ``$HOME`` is the user's home directory. This folder is not in the JupyterLab
  194. application directory because these settings are typically shared across
  195. Python environments. The location can be modified using the
  196. ``JUPYTERLAB_SETTINGS_DIR`` environment variable.
  197. `JSON5 <https://json5.org/>`__ files are automatically created in this folder
  198. recording the settings changes a user makes in the JupyterLab Advanced
  199. Settings Editor. The file names follow the pattern of
  200. ``<extension_name>/<plugin_name>.jupyterlab-settings``. These values override
  201. the default values given by extensions, as well as the default overrides from
  202. the :ref:`overrides.json <overridesjson>` file in the application's settings
  203. directory.
  204. JupyterLab Workspaces Directory
  205. -------------------------------
  206. JupyterLab sessions always reside in a workspace. Workspaces contain the state
  207. of JupyterLab: the files that are currently open, the layout of the
  208. application areas and tabs, etc. When the page is refreshed, the workspace is
  209. restored.
  210. By default, the location is ``$HOME/.jupyter/lab/workspaces/``, where
  211. ``$HOME`` is the user's home directory. This folder is not in the JupyterLab
  212. application directory, because these files are typically shared across Python
  213. environments. The location can be modified using the
  214. ``JUPYTERLAB_WORKSPACES_DIR`` environment variable.
  215. These files can be imported and exported to create default "profiles", using
  216. the :ref:`workspace command line tool <url-workspaces-cli>`.