directories.rst 12 KB

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