Skip to content

Structured validation report #461

Description

@liamhuber

I'm not in any rush on this, but what do you think of pulling this up into semantikon @samwaseda?

https://github.com/pyiron/pyiron_workflow/blob/ca9e53ab6538dc6f4b9ff30cad7dbe08b6ea78ca/pyiron_workflow/_wfms/validation.py#L175-L182

(Ok, that doesn't render because it's from another repo, here it is for readability, renamed while I'm at it:)

@dataclasses.dataclass(frozen=True)
class ValidationReport:
    valid: bool
    graph: rdflib.ConjunctiveGraph | rdflib.Graph
    text: str

    def __repr__(self):
        return self.text

It just wraps the current tuple. I.e. we'd switch this

return validate(g, shacl_graph=shacl)

To something like

validation_tuple = pyshacl.validate(g, shacl_graph=shacl)
return ValidationReport(valid=validation_tuple[0], ...)

I made it because I was tired of writing things like if report[0] and print(report[2]) and wanted to read/write if report.valid and print(report).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementCategory: New feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions