Exemplo n.º 1
0
def validate_model_on_storage(identifier, job_id):
    """
    This method validate uploaded model on storage OS / FS based on provided url from catalog db
    :param identifier: model's identifier
    :param job_id: uuid represent the ingestion id for the specific model
    """
    tileset = None
    im = model_ingestion.IngestionModel()
    _logger.info(f'Validating job:{identifier} placed on storage according tileset.json file')
    res = im.get_single_3rd_metadata(identifier)
    content = json.loads(res.text)
    url = content['links'].split(',')[3]
    if config.S3_TILE_LINK_SOURCE:
        tileset = get_tileset_from_s3(identifier, job_id)
        tileset = json.load(open(tileset))
    else:
        try:
            tileset = br.send_get_request(url)
        except Exception as e:
            _logger.error(f'Failed on downloading tileset.json file!\n'
                          f'Given url {url}\n'
                          f'With error: {str(e)}')

    _logger.info(f'New model placed OK on storage ')

    return tileset
Exemplo n.º 2
0
def get_watching_statuses():
    """
    This method return bool -> true if watcher is on, false if watcher
    """
    url = common.combine_url(config_ingestion.INGESTION_AGENT_URL,
                             config_ingestion.INGESTION_WATCHER_STATUS)
    resp = base_requests.send_get_request(url)
    return resp
def get_all_statuses(url):
    """
    This method return all statuses on db
    :param url: api's url
    :return: list[dict]
    """
    full_url = common.combine_url(url, config.STATUSES_API)
    resp = conn.send_get_request(full_url)
    return resp
def send_download_request(pkg_download_url):
    """
    This method send download request for package that was created on shared folder on storage
    :param pkg_download_url: download uri
    :return: status code + response content
    """
    _logger.info('Send download request: %s', pkg_download_url)
    resp = br.send_get_request(pkg_download_url)
    return resp.status_code, resp.content
Exemplo n.º 5
0
    def get_single_job_status(self, job_id):
        """This method return specific ingestion job status"""
        if not isinstance(job_id, str):
            _log.error(
                f'should be provided job id string expressed as uuid:\n{job_id} => {type(job_id)}'
            )
            raise TypeError('Request should be provided as valid json format')
        job_model_ingestion_url = common.combine_url(
            self._ingestion_job_service_url, config.INGESTION_3RD_JOB_STATUS,
            job_id)

        try:
            resp = br.send_get_request(job_model_ingestion_url)
            return resp
        except Exception as e:
            _log.error(
                f'Error on get response from ingestion job progress service with error {str(e)}'
            )
Exemplo n.º 6
0
    def get_single_3rd_metadata(self, identifier):
        """This method return specific exists metadata from catalog db"""
        if not isinstance(identifier, str):
            _log.error(
                f'should be provided identifier expressed as string:\n{identifier} => {type(identifier)}'
            )
            raise TypeError(
                'identifier should be provided as valid json format')
        model_metadata_on_catalog_url = common.combine_url(
            self._ingestion_catalog_url, config.INGESTION_CATALOG_MODEL_DATA,
            identifier)

        try:
            resp = br.send_get_request(model_metadata_on_catalog_url)
            return resp
        except Exception as e:
            _log.error(
                f'Error on get response from catalog db service with error {str(e)}'
            )
            raise e
def get_uuid_status(url, uuid):
    """This method return current state of export task by uuid created"""
    full_url = common.combine_url(url, uuid)
    resp = conn.send_get_request(full_url)
    return resp
Exemplo n.º 8
0
 def get_exportStatus(self):
     """
     This method send get request to trigger API and return all task status data
     """
     resp = br.send_get_request(self._get_status_url)
     return resp