From c379f46d9205127c1f0d2ef77e59ace1a2989105 Mon Sep 17 00:00:00 2001 From: dkeller9 Date: Wed, 14 May 2025 10:46:19 +0200 Subject: [PATCH 1/2] Add files via upload --- app/schemas/validation.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 app/schemas/validation.py diff --git a/app/schemas/validation.py b/app/schemas/validation.py new file mode 100644 index 000000000..a86422830 --- /dev/null +++ b/app/schemas/validation.py @@ -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. + From 9936cb457c835ed31ee7f26746370f1cee77deb3 Mon Sep 17 00:00:00 2001 From: dkeller9 Date: Wed, 14 May 2025 10:48:16 +0200 Subject: [PATCH 2/2] database model --- app/db/validation.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 app/db/validation.py diff --git a/app/db/validation.py b/app/db/validation.py new file mode 100644 index 000000000..c47c815bb --- /dev/null +++ b/app/db/validation.py @@ -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"" + + # 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