Sage-Bionetworks / schematic

Package for biomedical data model and metadata ingress management
https://schematicpy.readthedocs.io/en/stable/cli_reference.html
MIT License
22 stars 26 forks source link

Ensure validation will work with data_type list #803

Open mialy-defelice opened 2 years ago

mialy-defelice commented 2 years ago

Describe the bug In debugging a different issue ran into the issue of getting an error if the data_type was submitted as a list (as in the config file).

Make sure the validation takes in the data type from the config as a single value, or runs validation for each data_type specified. To Reproduce

Expected behavior

something like this:


    try:
        len(data_type) == 1
    except ValueError:
        logger.error(
            f"Can only validate a single data_type at a time."
        )

    #breakpoint()

    json_schema = fill_in_from_config(
        "json_schema",
        json_schema,
        ("model", "input", "validation_schema"),
        allow_none=True,
    )

    jsonld = get_from_config(CONFIG.DATA, ("model", "input", "location"))

    model_file_type = get_from_config(CONFIG.DATA, ("model", "input", "file_type"))

    metadata_model = MetadataModel(
        inputMModelLocation=jsonld, inputMModelLocationType=model_file_type
    )

    errors, warnings = metadata_model.validateModelManifest(
        manifestPath=manifest_path, rootNode=data_type[0], jsonSchema=json_schema, restrict_rules=restrict_rules, project_scope=project_scope,
    )

Priority (select one)

milen-sage commented 2 years ago

804