Giter Club home page Giter Club logo

linkml-validator's Introduction

Pyversions PyPi badge DOI PyPIDownloadsTotal PyPIDownloadsMonth codecov

LinkML - Linked Data Modeling Language

LinkML is a linked data modeling language following object-oriented and ontological principles. LinkML models are typically authored in YAML, and can be converted to other schema representation formats such as JSON or RDF.

This repo holds the tools for generating and working with LinkML. For the LinkML schema (metamodel), please see https://github.com/linkml/linkml-model

The complete documentation for LinkML can be found here:

linkml-validator's People

Contributors

deepakunni3 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

linkml-validator's Issues

TypeError: validate() got an unexpected keyword argument 'obj'

Hello,

When attempting to replicate the behavior described in the docs

https://linkml.io/linkml-validator/usage/#using-linkml-validator-as-a-module

with something like

from linkml.validator import Validator

my_dict={
    'species':'Homo sapiens'
}

schema_path='/Users/pgleasonbremer/coding_projects/altos/altos-labs-ontology/src/alo/schema/alo.yaml'

my_Validator=Validator(schema=schema_path)

my_Validator.validate(
    obj=my_dict,
    target_class='DataPackage'
)

I get

Traceback (most recent call last):
  File "/Users/pgleasonbremer/coding_projects/altos/linkml/mwe_validator_broken.py", line 12, in <module>
    my_Validator.validate(
TypeError: validate() got an unexpected keyword argument `obj`

however, I get no error when changing the keyword to instance

my_Validator.validate(
    instance=my_dict,
    target_class='DataPackage'
)

I would submit a PR to fix it, but i looked at the source and it looks like validate expects keyword obj, so i was a little confused, thanks.

Add a prefix validator plugin

Almost as a finer grain extension of the benefits of the range plugin, it would be great to have a prefix checking plugin.

I can take a shot at implementing it, the one question I had @deepakunni3 is whether there's a way to control the strictness of a plugin? I think officially in linkml prefixes are only advisory and invalid prefixes should only be warnings, but there are situations (like, when kgx output is first generated as part of an ingest) where I might want to fail on a prefix error.

One approach I could see taking is to make the plugin available as two different modules, prefix_validation and prefix_validation_strict and just share the code between them.

Unexpected validation failure in testing

I'm doing some development on Koza testing, and have run into an unexpected validation error against the Biolink model... I might be missing something obvious, but was hoping someone might have input.

Here's the error we're getting:

>       assert result.valid == True
E       assert False == True
E        +  where False = ValidationResult(plugin_name='JsonSchemaValidationPlugin', valid=False, validation_messages=[ValidationMessage(severit..., field=None, value=None, message="Additional properties are not allowed ('category', 'id', 'name' were unexpected)")]).valid

which seems to suggest that category, id, and name aren't valid slots for a named thing (?)

Here's the test code that yields the error:
from pathlib import Path

import pytest
from linkml_validator.validator import Validator

valid_gene = {
    "id": "BOGUS:12345",
    "name": "Bogus Gene 12345",
    "category": ["biolink:NamedThing", "biolink:Gene"],
}

invalid_gene = {
        "name": "Bogus Gene 98765",
        "type": "biolink:NamedThing"
}

model_schema = Path(__file__).parent.parent / 'resources' / 'biolink-model.yaml'


@pytest.mark.parametrize("gene", [valid_gene])
def test_valid_input(gene):
    validator = Validator(schema="tests/resources/biolink-model.yaml")
    v = validator.validate(obj=gene, target_class="Entity")
    result = v.validation_results[0]
    assert result.valid == True


@pytest.mark.parametrize("gene", [invalid_gene])
def test_invalid_input(gene):
    validator = Validator(schema="tests/resources/biolink-model.yaml")
    v = validator.validate(obj=gene, target_class="NamedThing")
    result = v.validation_results[0]
    assert result.valid == False

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.