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. ship-sync 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 ship-export to regenerate them.

source

absolute_import

def absolute_import(
    name, fname, level
):

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 *

source

ship_update

def ship_update(
    fname:str=None, # A Python file or directory to sync back to its source notebook(s)
):

Propagate changes in exported .py modules matching fname to the notebooks that created them