Example #1
0
def archive():
    data = request.get_json()

    submission_uuid = data.get('submission_uuid')
    exclude_types = data.get('exclude_types')
    alias_prefix = data.get('alias_prefix')

    if not submission_uuid:
        error = {
            'message':
            f'You must supply the parameter submission_uuid referring to an Ingest submission envelope uuid.'
        }
        return response_json(HTTPStatus.BAD_REQUEST, error)

    if config.DIRECT_SUBMISSION:
        direct_archiver = direct_archiver_from_config()
        submission = direct_archiver.archive_submission(submission_uuid)
        response = submission.as_dict(string_lists=True)
    else:
        ingest_api = IngestAPI(config.INGEST_API_URL)
        archiver = IngestArchiver(ingest_api=ingest_api,
                                  dsp_api=DataSubmissionPortal(
                                      config.DSP_API_URL),
                                  exclude_types=exclude_types,
                                  alias_prefix=alias_prefix)

        thread = threading.Thread(target=async_archive,
                                  args=(ingest_api, archiver, submission_uuid))
        thread.start()

        response = {'message': 'successfully triggered!'}

    return jsonify(response)
Example #2
0
def get_blockers(archive_submission_uuid: str):
    dsp_api = DataSubmissionPortal(config.DSP_API_URL)
    submission_url = dsp_api.get_submission_url(archive_submission_uuid)
    submission = ArchiveSubmission(dsp_api=dsp_api,
                                   dsp_submission_url=submission_url)
    blockers = submission.get_blockers()
    return jsonify(blockers)
Example #3
0
def get_validation_result(archive_submission_uuid: str):
    dsp_api = DataSubmissionPortal(config.DSP_API_URL)
    submission_url = dsp_api.get_submission_url(archive_submission_uuid)
    submission = ArchiveSubmission(dsp_api=dsp_api,
                                   dsp_submission_url=submission_url)
    result = submission.get_all_validation_result_details()
    return jsonify(result)
Example #4
0
def get_validation_errors(archive_submission_uuid: str):
    dsp_api = DataSubmissionPortal(config.DSP_API_URL)
    submission_url = dsp_api.get_submission_url(archive_submission_uuid)
    submission = ArchiveSubmission(dsp_api=dsp_api,
                                   dsp_submission_url=submission_url)
    validation_errors = submission.get_validation_error_report()
    return jsonify(validation_errors)
Example #5
0
def complete(dsp_submission_uuid: str):
    dsp_api = DataSubmissionPortal(config.DSP_API_URL)
    ingest_api = IngestAPI(config.INGEST_API_URL)

    thread = threading.Thread(target=async_complete,
                              args=(dsp_api, dsp_submission_uuid, ingest_api))
    thread.start()

    response = {'message': 'successfully triggered!'}
    return response_json(HTTPStatus.ACCEPTED, data=response)
Example #6
0
 def __init__(self, alias_prefix, output_dir, exclude_types, no_validation):
     self.manifests = []
     self.ingest_api = IngestAPI(config.INGEST_API_URL)
     self.dsp_api = DataSubmissionPortal(config.DSP_API_URL)
     now = datetime.datetime.utcnow().strftime("%Y-%m-%dT%H%M%S")
     self.output_dir = output_dir if output_dir else f"output/ARCHIVER_{now}"
     self.archiver = IngestArchiver(ingest_api=self.ingest_api,
                                    dsp_api=self.dsp_api,
                                    exclude_types=self.split_exclude_types(exclude_types),
                                    alias_prefix=alias_prefix,
                                    dsp_validation=not no_validation)
Example #7
0
def delete_archive_submission(dsp_submission_uuid: str):
    ingest_api = IngestAPI(config.INGEST_API_URL)
    dsp_api = DataSubmissionPortal(config.DSP_API_URL)
    ingest_archive_submission = ingest_api.get_archive_submission_by_dsp_uuid(
        dsp_submission_uuid)
    dsp_url = ingest_archive_submission['dspUrl']
    dsp_api.delete_submission(dsp_url)
    logger.info(f'Deleting DSP submission {dsp_url}')
    archive_submission_url = ingest_archive_submission['_links']['self'][
        'href']
    logger.info(f'Deleting Ingest Archive Submission {archive_submission_url}')
    response = ingest_api.delete(archive_submission_url)
    return response_json(HTTPStatus.OK, data=response)
Example #8
0
    def setUp(self):
        self.dsp_api = DataSubmissionPortal()

        with open(config.JSON_DIR + 'hca/biomaterials.json',
                  encoding=config.ENCODING) as data_file:
            hca_samples = json.loads(data_file.read())

        self.hca_submission = {'samples': hca_samples}
        self.ontology_api = MagicMock()
        self.ontology_api.expand_curie = MagicMock(
            return_value='http://purl.obolibrary.org/obo/UO_0000015')

        self.ingest_api = MagicMock()
        self.ingest_api.url = 'ingest_url'
        self.ingest_api.get_concrete_entity_type = MagicMock(
            return_value='donor_organism')

        self.converter = SampleConverter(ontology_api=self.ontology_api)
        self.converter.ingest_api = self.ingest_api
        pass