コード例 #1
0
def upgrade(all):
    """Install/Upgrade polyaxon or polyxon-cli."""
    try:
        project_name = PROJECT_NAME if all else PROJECT_CLI_NAME
        pip_upgrade(project_name)
    except Exception as e:
        logger.error(e)
コード例 #2
0
 def delete_dataset(self, data_id):
     request_url = self._get_url(data_id)
     try:
         # data delete is a synchronous process, it can take a long time
         self.delete(request_url, timeout=60)
         return True
     except PolyaxonException as e:
         logger.error("Data %s: ERROR! %s", data_id, e.message)
         return False
コード例 #3
0
ファイル: base.py プロジェクト: mouradmourafiq/polyaxon-cli
    def check_response_status(response, endpoint):
        """Check if response is successful. Else raise Exception."""

        if 200 <= response.status_code < 300:
            return response

        logger.error("Request to {} failed with status code {}".format(
            endpoint, response.status_code),
                     text=response.text)

        exception = ERRORS_MAPPING.get(response.status_code, PolyaxonHTTPError)
        raise exception(endpoint=endpoint,
                        response=response,
                        message=response.text,
                        status_code=response.status_code)
コード例 #4
0
ファイル: base.py プロジェクト: mouradmourafiq/polyaxon-cli
    def get_config_file_path(cls):
        if not cls.IS_GLOBAL:
            # local to this directory
            return os.path.join('.', cls.CONFIG_FILE_NAME)

        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 create_dataset(self, data):
     """
     Create a temporary directory for the tar file that will be removed at
     the end of the operation.
     """
     try:
         logger.info("Making create request to server...")
         post_body = data.to_dict()
         post_body["resumable"] = True
         response = self.post(self._get_url(), json=post_body)
         return response.json()
     except BadRequestError as e:
         if 'Dataset not found, ID' in e.message:
             logger.error(
                 "Data create: ERROR! "
                 "Please run 'polyaxon data init DATASET_NAME' before upload."
             )
         else:
             logger.error('Data create: ERROR! %s', e.message)
         return None
     except PolyaxonException as e:
         logger.error("Data create: ERROR! %s", e.message)
         return None
コード例 #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))