-
Notifications
You must be signed in to change notification settings - Fork 0
Validation proposal #166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dkeller9
wants to merge
2
commits into
main
Choose a base branch
from
validation_proposal
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Validation proposal #166
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from sqlalchemy import Column, Integer, String, Table, ForeignKey | ||
from sqlalchemy.ext.declarative import declarative_base | ||
from sqlalchemy.orm import relationship | ||
from sqlalchemy.dialects.postgresql import ARRAY # Using PostgreSQL's array type for sets | ||
|
||
Base = declarative_base() | ||
|
||
class Validation(Base): | ||
__tablename__ = "validations" | ||
|
||
id = Column(Integer, primary_key=True, index=True) | ||
entity_type = Column(String, nullable=False, index=True) | ||
|
||
# Using PostgreSQL ARRAY type to store sets of strings | ||
# Note: This doesn't guarantee uniqueness like Python sets do - application logic would need to enforce that | ||
must_pass_to_upload = Column(ARRAY(String), nullable=True) | ||
must_run_upon_upload = Column(ARRAY(String), nullable=True) | ||
must_pass_to_simulate = Column(ARRAY(String), nullable=True) | ||
|
||
def __repr__(self): | ||
return f"<Validation(entity_type='{self.entity_type}')>" | ||
|
||
# Helper methods to work with the array fields as sets | ||
def get_must_pass_to_upload(self): | ||
return set(self.must_pass_to_upload) if self.must_pass_to_upload else set() | ||
|
||
def set_must_pass_to_upload(self, value_set): | ||
self.must_pass_to_upload = list(value_set) if value_set else None | ||
|
||
def get_must_run_upon_upload(self): | ||
return set(self.must_run_upon_upload) if self.must_run_upon_upload else set() | ||
|
||
def set_must_run_upon_upload(self, value_set): | ||
self.must_run_upon_upload = list(value_set) if value_set else None | ||
|
||
def get_must_pass_to_simulate(self): | ||
return set(self.must_pass_to_simulate) if self.must_pass_to_simulate else set() | ||
|
||
def set_must_pass_to_simulate(self, value_set): | ||
self.must_pass_to_simulate = list(value_set) if value_set else None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from pydantic import BaseModel, ConfigDict | ||
from typing import Optional, Set | ||
|
||
class Validation(BaseModel): | ||
entity_type: str # from predetermined vocabulary (an entity class in db) | ||
must_pass_to_upload: Optional[Set[str]] = None # set of validation script paths in github repo. Each has a function with output pass or fail. Optional output (log fails) If any fails, the entity can’t be uploaded to the database. | ||
must_run_upon_upload: Optional[Set[str]] = None #set of validation script paths in github repo that will be launched when uploading an artifact. The result will be available as annotation to the entity. | ||
|
||
must_pass_to_simulate: Optional[Set[str]] = None #set of validation script paths in github repo that must pass to simulate. Will be launched when uploading an artifact, the result will be available as annotation to the entity. | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure I understand :( . Can you give an example of 1 instance of this ? and how it would be consumed ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be easier to look at the schema rather than the data model. So let's say the user contributes a new morphology. The validation logic looks up the morphology entity type in the table then applies the "must_pass_to_upload" validations. If these are successful it runs the validations in "must_run_upon_upload" which annotates the entity, and "must_pass_to_simulate" which generates additional validations needed for the artifact to be simulated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, then it is not a validation, it is rather something like a "validation plan".
also what does the list of string contains ? I know it is a list of validations. but how do we go from a string to the actual execution of a code ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the validation plan schema stored in the database. The string contains a relative path in a github repo, for example "/morphologies/validate_morphology.py" I wrote a simple "validate_morphology.py" script that sees if it can be read in by NeuroM and returns an error if not. There will need to be some support logic that processes the lists, which I can add to entitycore once we are satisfied with this plan.