Пример #1
0
def get_version(package):
    import pkg_resources

    try:
        return pkg_resources.get_distribution(package).version
    except pkg_resources.DistributionNotFound:
        logger.error('`%s` is not installed', package)
Пример #2
0
def upgrade(lib):
    """Install/Upgrade polyxon-cli or polyaxon-lib."""
    try:
        project_name = PROJECT_LIB_NAME if lib else PROJECT_CLI_NAME
        pip_upgrade(project_name)
    except Exception as e:
        logger.error(e)
Пример #3
0
 def _create_dir(dir_path):
     if not os.path.exists(dir_path):
         try:
             os.makedirs(dir_path)
         except OSError:
             # Except permission denied and potential race conditions
             # in multi-threaded environments.
             logger.error('Could not create config directory `%s`',
                          dir_path)
Пример #4
0
    def get_config_file_path(cls):
        if not cls.IS_GLOBAL:
            # local to this directory
            base_path = os.path.join('.')
        else:
            base_path = os.path.expanduser('~')
            if not os.access(base_path, os.W_OK):
                base_path = '/tmp'

            base_path = os.path.join(base_path, '.polyaxon')

            if not os.path.exists(base_path):
                try:
                    os.makedirs(base_path)
                except OSError:
                    # Except permission denied and potential race conditions
                    # in multi-threaded environments.
                    logger.error(
                        'Could not create config directory `{}`'.format(
                            base_path))

        return os.path.join(base_path, cls.CONFIG_FILE_NAME)
Пример #5
0
def upgrade():
    """Install/Upgrade polyaxon-cli."""
    try:
        pip_upgrade(PROJECT_CLI_NAME)
    except Exception as e:
        logger.error(e)
Пример #6
0
def get_version(pkg):
    try:
        version = pkg_resources.get_distribution(pkg).version
        return version
    except pkg_resources.DistributionNotFound:
        logger.error('`{}` is not installed'.format(pkg))