doit#
The use of
doitis an implementation detail, and is subject to change!
Under the hood, the CLI is powered by
doit, a lightweight task engine in python comparable
to make.
Using Tasks with the API#
The LiteManager collects all the tasks from Addons, and can optionally accept a
task_prefix in case you need to integrate with existing tasks.
from jupyterlite_core.manager import LiteManager
manager = LiteManager(task_prefix="lite_")
manager.initialize()
manager.doit_run("lite_status")
. lite_pre_status:lite_static:jupyter-lite.json
tarball: jupyterlite-app-0.8.0-alpha.1.tgz 15MB
output: /tmp/_my_lite_dir__y1iqaop/_output
lite dir: /tmp/_my_lite_dir__y1iqaop
apps:
sourcemaps: True
unused packages: True
. lite_status:lite_archive:archive
. lite_status:lite_contents:contents
contents: 0 files
. lite_status:lite_icons:icons
favicon files: 0 files
. lite_status:lite_jupyterlite-pyodide-kernel-pyodide:pyodide
URL: None
archive: []
cache: 0 files
local: 0 files
. lite_status:lite_lite:jupyter-lite.json
. lite_status:lite_mimetypes:jupyter-lite.json
filetypes: 36
. lite_status:lite_serve:contents
url: http://127.0.0.1:8000/
server: tornado
headers:
. lite_status:lite_settings:overrides
overrides.json: 0
. lite_status:lite_translation:translation
translation files: 0 files
. lite_status:lite_workspaces:workspaces:files
workspaces:
0
Custom Tasks and %doit#
doit offers an IPython
magic, enabled with
an extension. This can be combined to create highly reactive build tools for creating
very custom sites.
%reload_ext doit
It works against the __main__ namespace, which won’t have anything by default.
%doit list
All the JupyterLite tasks can be added by updating __main__ via globals
globals().update(manager._doit_tasks)
Now when a new task is created, it can reference other tasks and targets.
def task_hello():
return dict(actions=[lambda: print("HELLO!")], task_dep=["lite_post_status"])
%doit -v2 hello
Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/jupyterlite/envs/1881/lib/python3.12/site-packages/doit/dependency.py", line 155, in __init__
self._dbm = ddbm.open(self.name, 'c')
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/docs/.asdf/installs/python/3.12.10/lib/python3.12/dbm/__init__.py", line 95, in open
return mod.open(file, flag, mode)
^^^^^^^^^^^^^^^^^^^^^^^^^^
_gdbm.error: [Errno 11] Resource temporarily unavailable: '/home/docs/.ipython/profile_default/db/.doit.db'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/jupyterlite/envs/1881/lib/python3.12/site-packages/doit/doit_cmd.py", line 294, in run
return command.parse_execute(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/docs/checkouts/readthedocs.org/user_builds/jupyterlite/envs/1881/lib/python3.12/site-packages/doit/cmd_base.py", line 150, in parse_execute
return self.execute(params, args)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/docs/checkouts/readthedocs.org/user_builds/jupyterlite/envs/1881/lib/python3.12/site-packages/doit/cmd_base.py", line 549, in execute
self.dep_manager = Dependency(
^^^^^^^^^^^
File "/home/docs/checkouts/readthedocs.org/user_builds/jupyterlite/envs/1881/lib/python3.12/site-packages/doit/dependency.py", line 510, in __init__
self.backend = db_class(backend_name, codec=codec_cls())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/docs/checkouts/readthedocs.org/user_builds/jupyterlite/envs/1881/lib/python3.12/site-packages/doit/dependency.py", line 170, in __init__
raise DatabaseException(message)
doit.dependency.DatabaseException: [Errno 11] Resource temporarily unavailable: '/home/docs/.ipython/profile_default/db/.doit.db'