directories.rst 12 KB

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