test_eq(absolute_import('xyz', 'nbdev', 0), 'xyz')
test_eq(absolute_import('', 'nbdev', 1), 'nbdev')
test_eq(absolute_import(None, 'nbdev', 1), 'nbdev')
test_eq(absolute_import('core', 'nbdev', 1), 'nbdev.core')
test_eq(absolute_import('core', 'nbdev/vision', 2), 'nbdev.core') # from ..core import *
test_eq(absolute_import('transform', 'nbdev/vision', 1), 'nbdev.vision.transform') # from .transform import *
test_eq(absolute_import('notebook.core', 'nbdev/data', 2), 'nbdev.notebook.core') # from ..notebook.core import *sync
Propagate small changes in the library back to notebooks
The library is primarily developed in notebooks so any big changes should be made there. But sometimes, it’s easier to fix small bugs or typos in the modules directly. nbdev_update is the function that will propagate those changes back to the corresponding notebooks.
Note that you can’t create new cells or reorder cells with that functionality, so your corrections should remain limited. Exported .py files must contain cell IDs (format # %% path/nb.ipynb #cell_id); if your exports don’t have IDs, run nbdev_export to regenerate them.
absolute_import
def absolute_import(
name, fname, level
):
Unwarps a relative import in name according to fname
nbdev_update
def nbdev_update(
fname:str=None, # A Python file name to update
):
Propagate change in modules matching fname to notebooks that created them