import os, pathlib, tempfile, shutil, atexit, hashlib
from IPython.display import *
from IPython import get_ipython # needed for `jupyter_execute` because magics?
import IPython
if "TMP_DIR" not in globals():
TMP_DIR = pathlib.Path(tempfile.mkdtemp(prefix="_my_lite_dir_"))
def clean():
shutil.rmtree(TMP_DIR)
atexit.register(clean)
os.chdir(TMP_DIR)
print(pathlib.Path.cwd())
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.manager import LiteManager
manager = LiteManager(
task_prefix="lite_"
)
manager.initialize()
manager.doit_run("lite_status")
%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