directories.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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. These directories for are used configuration data that allow layering of config in file(s) in ``<jupyter_config_path>/labconfig``.
  59. The Jupyter configuration path priority order can be seen by typing ``jupyter --paths``. The values are combined into a single config object.
  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/pageconfig.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. JupyterLab Application Directory
  105. --------------------------------
  106. The application directory contains the main JupyterLab application files,
  107. including built assets, files for rebuilding JupyterLab, installed extensions
  108. and linked packages, etc.
  109. By default, the application directory is at
  110. ``<sys-prefix>/share/jupyter/lab``, where ``<sys-prefix>`` is the
  111. site-specific directory prefix of the current Python environment. You can
  112. query the current application path by running ``jupyter lab path``. The
  113. application directory can be overridden using the ``--app-dir`` command-line
  114. option in any of the JupyterLab commands, or by setting the ``JUPYTERLAB_DIR``
  115. environment variable.
  116. We recommend users not install JupyterLab in a system location on Unix-like
  117. systems, because then the application directory will be read-only. Instead,
  118. use a conda environment or ``pip install --user jupyterlab`` so the
  119. application directory is writeable by the user.
  120. This directory location and semantics do *not* follow the standard Jupyter
  121. config semantics because we need to build a single unified application, and
  122. the default config location for Jupyter is at the user level (user's home
  123. directory). By explicitly using a sys-prefix directory, we can ensure better
  124. isolation in virtual environments.
  125. The JupyterLab application directory contains the subdirectories
  126. ``extensions``, ``schemas``, ``settings``, ``staging``, ``static``, and
  127. ``themes``. In the rest of this section, we will explain each subdirectory.
  128. .. _extensions-1:
  129. extensions
  130. ^^^^^^^^^^
  131. The ``extensions`` directory has the packed tarballs for each of the
  132. installed extensions for the app. If the application directory is not
  133. the same as the ``sys-prefix`` directory, the extensions installed in
  134. the ``sys-prefix`` directory will be used in the app directory. If an
  135. extension is installed in the app directory that exists in the
  136. ``sys-prefix`` directory, it will shadow the ``sys-prefix`` version.
  137. Uninstalling an extension will first uninstall the shadowed extension,
  138. and then attempt to uninstall the ``sys-prefix`` version if called
  139. again. If the ``sys-prefix`` version cannot be uninstalled, its plugins
  140. can still be ignored using ``ignoredPackages`` metadata in ``settings``.
  141. schemas
  142. ^^^^^^^
  143. The ``schemas`` directory contains `JSON
  144. Schemas <http://json-schema.org/>`__ that describe the settings used by
  145. individual extensions. Users may edit these settings using the
  146. JupyterLab Advanced Settings Editor.
  147. settings
  148. ^^^^^^^^
  149. The ``settings`` directory may contain ``page_config.json``, ``overrides.json``, and/or
  150. ``build_config.json`` files, depending on which configurations are
  151. set on your system.
  152. .. _page_configjson:
  153. page_config.json (deprecated)
  154. """""""""""""""""""""""""""""
  155. This file is considered deprecated. This file can have similar data as the ``page_config.json``
  156. file in the LabConfig Directories, except that ``disabledExtensions`` and ``deferredExtensions`` are given as arrays of strings.
  157. An example of a ``page_config.json`` file is:
  158. .. code:: json
  159. {
  160. "disabledExtensions": [
  161. "@jupyterlab/toc"
  162. ],
  163. "terminalsAvailable": false
  164. }
  165. .. _overridesjson:
  166. overrides.json
  167. """"""""""""""
  168. You can override default values of the extension settings by defining new
  169. default values in an ``overrides.json`` file. For example, if you would like
  170. to override the default theme to be the dark theme, an ``overrides.json`` file
  171. containing the following lines should be added in the application settings
  172. directory (by default this is the ``share/jupyter/lab/settings`` folder).
  173. .. code:: json
  174. {
  175. "@jupyterlab/apputils-extension:themes": {
  176. "theme": "JupyterLab Dark"
  177. }
  178. }
  179. .. _build_configjson:
  180. build_config.json
  181. """""""""""""""""
  182. The ``build_config.json`` file is used to track the local directories
  183. that have been installed using
  184. ``jupyter labextension install <directory>``, as well as core extensions
  185. that have been explicitly uninstalled. An example of a
  186. ``build_config.json`` file is:
  187. .. code:: json
  188. {
  189. "uninstalled_core_extensions": [
  190. "@jupyterlab/markdownwidget-extension"
  191. ],
  192. "local_extensions": {
  193. "@jupyterlab/python-tests": "/path/to/my/extension"
  194. }
  195. }
  196. staging and static
  197. ^^^^^^^^^^^^^^^^^^
  198. The ``static`` directory contains the assets that will be loaded by the
  199. JupyterLab application. The ``staging`` directory is used to create the
  200. build and then populate the ``static`` directory.
  201. Running ``jupyter lab`` will attempt to run the ``static`` assets in the
  202. application directory if they exist. You can run ``jupyter lab --core-mode``
  203. to load the core JupyterLab application from the installation directory (i.e.,
  204. the application without any extensions) instead.
  205. If JupyterLab is launched and the static assets are not present, it will
  206. display an error in the console and in the browser.
  207. themes
  208. ^^^^^^
  209. The ``themes`` directory contains assets (such as CSS and icons) for
  210. JupyterLab theme extensions.
  211. JupyterLab User Settings Directory
  212. ----------------------------------
  213. The user settings directory contains the user-level settings for Jupyter
  214. extensions.
  215. By default, the location is ``$HOME/.jupyter/lab/user-settings/``, where
  216. ``$HOME`` is the user's home directory. This folder is not in the JupyterLab
  217. application directory because these settings are typically shared across
  218. Python environments. The location can be modified using the
  219. ``JUPYTERLAB_SETTINGS_DIR`` environment variable.
  220. `JSON5 <https://json5.org/>`__ files are automatically created in this folder
  221. recording the settings changes a user makes in the JupyterLab Advanced
  222. Settings Editor. The file names follow the pattern of
  223. ``<extension_name>/<plugin_name>.jupyterlab-settings``. These values override
  224. the default values given by extensions, as well as the default overrides from
  225. the :ref:`overrides.json <overridesjson>` file in the application's settings
  226. directory.
  227. JupyterLab Workspaces Directory
  228. -------------------------------
  229. JupyterLab sessions always reside in a workspace. Workspaces contain the state
  230. of JupyterLab: the files that are currently open, the layout of the
  231. application areas and tabs, etc. When the page is refreshed, the workspace is
  232. restored.
  233. By default, the location is ``$HOME/.jupyter/lab/workspaces/``, where
  234. ``$HOME`` is the user's home directory. This folder is not in the JupyterLab
  235. application directory, because these files are typically shared across Python
  236. environments. The location can be modified using the
  237. ``JUPYTERLAB_WORKSPACES_DIR`` environment variable.
  238. These files can be imported and exported to create default "profiles", using
  239. the :ref:`workspace command line tool <url-workspaces-cli>`.