Skip to main content

migrate

Migrating IPython < 4.0 to Datalayer.

This copies configuration and resources to their new locations in Datalayer.

Migrations:

  • .ipython/

    • nbextensions -> DATALAYER_DATA_DIR/nbextensions
    • kernels -> DATALAYER_DATA_DIR/kernels
  • .ipython/profile_default/

    • static/custom -> .datalayer/custom

    • nbconfig -> .datalayer/nbconfig

    • security/

      • notebook_secret, notebook_cookie_secret, nbsignatures.db -> DATALAYER_DATA_DIR
    • ipython_{notebook,nbconvert,qtconsole}config.py -> .datalayer/datalayer{name}_config.py

def get_ipython_dir() -> str

Return the IPython directory location.

Not imported from IPython because the IPython implementation ensures that a writable directory exists, creating a temporary directory if not. We don't want to trigger that when checking if migration should happen.

We only need to support the IPython < 4 behavior for migration, so importing for forward-compatibility and edge cases is not important.

Returns

  • str

    The path to the IPython directory.

def migrate_dir(src: str, dst: str) -> bool

Migrate a directory from src to dst.

Parameters

  • src : str

    The source directory.

  • dst : str

    The destination directory.

Returns

  • bool

    True if the migration was successful, False otherwise.

def migrate_file(src: str, dst: str, substitutions: Optional[dict[Any, Any]] = None) -> bool

Migrate a single file from src to dst.

substitutions is an optional dict of {regex: replacement} for performing replacements on the file.

Parameters

  • src : str

    The source file.

  • dst : str

    The destination file.

  • substitutions : Optional[dict[Any, Any]]

    A dictionary of regex patterns and their replacements.

Returns

  • bool

    True if the migration was successful, False otherwise.

def migrate_one(src: str, dst: str) -> bool

Migrate one item.

dispatches to migrate_dir/_file

Parameters

  • src : str

    The source path.

  • dst : str

    The destination path.

Returns

  • bool

    True if the migration was successful, False otherwise.

def migrate_static_custom(src: str, dst: str) -> bool

Migrate non-empty custom.js,css from src to dst.

src, dst are 'custom' directories containing custom.{js,css}

Parameters

  • src : str

    The source directory.

  • dst : str

    The destination directory.

Returns

  • bool

    True if any files were migrated, False otherwise.

def migrate_config(name: str, env: dict[str, typing.Any]) -> list[str]

Migrate a config file.

Includes substitutions for updated configurable names.

Parameters

  • name : str

    The name of the config file (without extension).

  • env : dict[str, Any]

    The environment variables to use for path expansion.

Returns

  • list[str]

    A list of migrated config file paths.

def migrate() -> bool

Migrate IPython configuration to Datalayer.

Returns

  • bool

    True if any files were migrated, False otherwise.

class DatalayerMigrate(**kwargs: 't.Any') -> 'None'

A Datalayer Migration App.

start() -> None

Start the application.