Exemplo n.º 1
0
def validate_metadata_file(convention_path, metadata_path):
    with open(convention_path) as f:
        convention = json.load(f)
    metadata = CellMetadata(metadata_path, '', '')
    print(f'Validating {metadata_path}')
    collect_jsonschema_errors(metadata, convention)
    validate_collected_ontology_data(metadata, convention)
    serialize_issues(metadata)
    report_issues(metadata)
    exit_if_errors(metadata)
Exemplo n.º 2
0
def validate_metadata_file(metadata_path):
    placeholder = 'SCP555' # TODO: Refactor CellMetadata to not require this
    metadata = CellMetadata(metadata_path, '', '', study_accession=placeholder)
    print(f'Validating {metadata_path}')

    convention_path = download_from_bucket(IngestPipeline.JSON_CONVENTION)
    with open(convention_path) as file:
        convention = json.load(file)

    validate_input_metadata(metadata, convention)
    serialize_issues(metadata)
    report_issues(metadata)
    exit_if_errors(metadata)
Exemplo n.º 3
0
def validate_metadata_file(parsed_args, connection):
    metadata_path = parsed_args.metadata_file
    study_name = parsed_args.study_name
    dry_run = parsed_args.dry_run
    verbose = parsed_args.verbose
    study_accession_res = connection.get_study_attribute(study_name=study_name,
                                                         attribute='accession',
                                                         dry_run=dry_run)
    # Needed dummy values for CellMetadata
    study_file = ObjectId('addedfeed000000000000000')
    study_file_id = ObjectId('addedfeed000000000000001')
    if succeeded(study_accession_res):
        if verbose:
            print(
                f'Study accession {study_accession_res} retrieved for {study_name}'
            )
        study_accession = study_accession_res.get('study_attribute')
        metadata = CellMetadata(
            metadata_path,
            study_file,
            study_file_id,
            study_accession=str(study_accession),
        )
        convention_res = connection.do_get(
            command=get_api_base(parsed_args) +
            'metadata_schemas/alexandria_convention/latest/json',
            dry_run=dry_run,
        )
        if succeeded(convention_res):
            if verbose:
                print(f'Retreieved file for latest metdata convention')
            convention = convention_res["response"].json()
            validate_input_metadata(metadata, convention)
            serialize_issues(metadata)
            report_issues(metadata)
            exit_if_errors(metadata)