absolute_import
def absolute_import(
name, fname, level
):Unwarps a relative import in name according to fname
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 command 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.
Unwarps a relative import in name according to fname
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 *Propagate change in modules matching fname to notebooks that created them