upload library, update jobs using the same major version,
    and delete libraries with the same major and lower minor versions
    (depending on update_jobs and cleanup flags)

    Parameters
    ----------
    logger: logging object
        configured in cli_commands.py
    path: string
        path with name of egg as output from setuptools
        (e.g. dist/new_library-1.0.0-py3.6.egg)
    token: string
        Databricks API key
    folder: string
        Databricks folder to upload to
        (e.g. '/Users/my_email@fake_organization.com/')
    update_jobs: bool
        if true, jobs using this library will be updated to point to the
            new version
        if false, will not touch jobs or other library versions at all
    cleanup: bool
        if true, outdated libraries will be deleted
        if false, nothing will be deleted

    Side Effects
    ------------
    new library in Databricks
    if update_jobs is true, then updated jobs
    if update_jobs and cleanup are true, removed outdated libraries

def update_databricks(logger, path, token, folder, update_jobs, cleanup):
    """
    upload library, update jobs using the same major version,
    and delete libraries with the same major and lower minor versions
    (depending on update_jobs and cleanup flags)

    Parameters
    ----------
    logger: logging object
        configured in cli_commands.py
    path: string
        path with name of egg as output from setuptools
        (e.g. dist/new_library-1.0.0-py3.6.egg)
    token: string
        Databricks API key
    folder: string
        Databricks folder to upload to
        (e.g. '/Users/my_email@fake_organization.com/')
    update_jobs: bool
        if true, jobs using this library will be updated to point to the
            new version
        if false, will not touch jobs or other library versions at all
    cleanup: bool
        if true, outdated libraries will be deleted
        if false, nothing will be deleted

    Side Effects
    ------------
    new library in Databricks
    if update_jobs is true, then updated jobs
    if update_jobs and cleanup are true, removed outdated libraries
    """

    config = _load_config(CFG_FILE)
    try:
        host = config.get(PROFILE, 'host')
    except NoOptionError:
        raise ValueError('no host provided: please run `apparate configure`'
                         ' to get set up')
    try:
        prod_folder = config.get(PROFILE, 'prod_folder')
    except NoOptionError:
        raise ValueError('no prod_folder provided: please run '
                         '`apparate configure` to get set up')

    match = FileNameMatch(basename(path))

    try:
        load_library(path, match, folder, token, host)
        logger.info(
            'new library {}-{} loaded to Databricks'
            .format(match.library_name, match.version)
        )
    except APIError as err:
        if err.code == 'http 500' and 'already exists' in err.message:
            logger.info(
                'This version ({}) already exists: '.format(match.version) +
                'if a change has been made please update your version number. '
                'Note this error can also occur if you are uploading a jar '
                'and an egg already exists with the same name and version, '
                'or vice versa. In this case you will need to choose a '
                'different library name or a different folder for either the '
                'egg or the jar.'
            )
            return
        else:
            raise err

    if update_jobs and folder == prod_folder:
        library_map, id_nums = get_library_mapping(
            logger,
            prod_folder,
            token,
            host,
        )
        library_uri = [
            uri for uri, tmp_match in library_map.items()
            if (
                match.library_name == tmp_match.library_name
                and match.version == tmp_match.version
            )
        ][0]
        library_path = 'dbfs:/FileStore/jars/' + library_uri

        job_list = get_job_list(logger, match, library_map, token, host)
        logger.info(
            'current major version of library used by jobs: {}'
            .format(', '.join([i['job_name'] for i in job_list]))
        )

        if len(job_list) != 0:
            update_job_libraries(
                logger,
                job_list,
                match,
                library_path,
                token,
                host,
            )
            logger.info(
                'updated jobs: {}'
                .format(', '.join([i['job_name'] for i in job_list]))
            )

        if cleanup:
            old_versions = delete_old_versions(
                logger,
                match,
                id_nums=id_nums,
                token=token,
                prod_folder=prod_folder,
                host=host,
            )
            logger.info(
                'removed old versions: {}'.format(', '.join(old_versions))
            )