directories.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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. .. _application_directory:
  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. .. _application_settings_directory:
  148. settings
  149. ^^^^^^^^
  150. The ``settings`` directory inside the :ref:`JupyterLab Application directory
  151. <application_directory>` may contain ``page_config.json``, ``overrides.json``,
  152. and/or ``build_config.json`` files.
  153. .. _page_configjson:
  154. page_config.json (deprecated)
  155. """""""""""""""""""""""""""""
  156. This file is considered deprecated. This file can have similar data as the ``page_config.json``
  157. file in the LabConfig Directories, except that ``disabledExtensions`` and ``deferredExtensions`` are given as arrays of strings.
  158. An example of a ``page_config.json`` file is:
  159. .. code:: json
  160. {
  161. "disabledExtensions": [
  162. "@jupyterlab/toc"
  163. ],
  164. "terminalsAvailable": false
  165. }
  166. .. _overridesjson:
  167. overrides.json
  168. """"""""""""""
  169. You can override default values of the extension settings by defining new
  170. default values in an ``overrides.json`` file. For example, if you would like
  171. to override the default theme to be the dark theme, create an
  172. ``overrides.json`` file containing the following lines in the
  173. :ref:`application settings directory <application_settings_directory>` (for
  174. example, if the :ref:`application_directory` is
  175. ``<sys.prefix>/local/share/jupyter/lab``, create this file at
  176. ``<sys.prefix>/local/share/jupyter/lab/settings/overrides.json``).
  177. .. code:: json
  178. {
  179. "@jupyterlab/apputils-extension:themes": {
  180. "theme": "JupyterLab Dark"
  181. }
  182. }
  183. .. _build_configjson:
  184. build_config.json
  185. """""""""""""""""
  186. The ``build_config.json`` file is used to track the local directories
  187. that have been installed using
  188. ``jupyter labextension install <directory>``, as well as core extensions
  189. that have been explicitly uninstalled. An example of a
  190. ``build_config.json`` file is:
  191. .. code:: json
  192. {
  193. "uninstalled_core_extensions": [
  194. "@jupyterlab/markdownwidget-extension"
  195. ],
  196. "local_extensions": {
  197. "@jupyterlab/python-tests": "/path/to/my/extension"
  198. }
  199. }
  200. staging and static
  201. ^^^^^^^^^^^^^^^^^^
  202. The ``static`` directory contains the assets that will be loaded by the
  203. JupyterLab application. The ``staging`` directory is used to create the
  204. build and then populate the ``static`` directory.
  205. Running ``jupyter lab`` will attempt to run the ``static`` assets in the
  206. application directory if they exist. You can run ``jupyter lab --core-mode``
  207. to load the core JupyterLab application from the installation directory (i.e.,
  208. the application without any extensions) instead.
  209. If JupyterLab is launched and the static assets are not present, it will
  210. display an error in the console and in the browser.
  211. themes
  212. ^^^^^^
  213. The ``themes`` directory contains assets (such as CSS and icons) for
  214. JupyterLab theme extensions.
  215. JupyterLab User Settings Directory
  216. ----------------------------------
  217. The user settings directory contains the user-level settings for Jupyter
  218. extensions.
  219. By default, the location is ``$HOME/.jupyter/lab/user-settings/``, where
  220. ``$HOME`` is the user's home directory. This folder is not in the JupyterLab
  221. application directory because these settings are typically shared across
  222. Python environments. The location can be modified using the
  223. ``JUPYTERLAB_SETTINGS_DIR`` environment variable.
  224. `JSON5 <https://json5.org/>`__ files are automatically created in this folder
  225. recording the settings changes a user makes in the JupyterLab Advanced
  226. Settings Editor. The file names follow the pattern of
  227. ``<extension_name>/<plugin_name>.jupyterlab-settings``. These values override
  228. the default values given by extensions, as well as the default overrides from
  229. the :ref:`overrides.json <overridesjson>` file in the application's settings
  230. directory.
  231. JupyterLab Workspaces Directory
  232. -------------------------------
  233. JupyterLab sessions always reside in a workspace. Workspaces contain the state
  234. of JupyterLab: the files that are currently open, the layout of the
  235. application areas and tabs, etc. When the page is refreshed, the workspace is
  236. restored.
  237. By default, the location is ``$HOME/.jupyter/lab/workspaces/``, where
  238. ``$HOME`` is the user's home directory. This folder is not in the JupyterLab
  239. application directory, because these files are typically shared across Python
  240. environments. The location can be modified using the
  241. ``JUPYTERLAB_WORKSPACES_DIR`` environment variable.
  242. These files can be imported and exported to create default "profiles", using
  243. the :ref:`workspace command line tool <url-workspaces-cli>`.