diff --git a/chord_drs/models.py b/chord_drs/models.py index c317d05..edd5a7f 100644 --- a/chord_drs/models.py +++ b/chord_drs/models.py @@ -22,13 +22,18 @@ Base = declarative_base() -class DrsMixin: - # IDs (PKs) must remain outside the mixin! +class DrsBlob(Base): + __tablename__ = "drs_object" + + id = Column(String, primary_key=True) + location = Column(String(500), nullable=False) + created = Column(DateTime, server_default=func.now()) checksum = Column(String(64), nullable=False) size = Column(Integer, default=0) name = Column(String(250), nullable=True) description = Column(String(1000), nullable=True) + # Permissions/Bento-specific project & dataset tagging for DRS items # TODO: Make some of these not nullable in the future: project_id = Column(String(64), nullable=True) # Nullable for backwards-compatibility @@ -36,13 +41,6 @@ class DrsMixin: data_type = Column(String(24), nullable=True) # NULL if multi-data type or something else public = Column(Boolean, default=False, nullable=False) # If true, the object is accessible by anyone - -class DrsBlob(Base, DrsMixin): - __tablename__ = "drs_object" - - id = Column(String, primary_key=True) - location = Column(String(500), nullable=False) - def __init__(self, *args, **kwargs): logger = current_app.logger diff --git a/chord_drs/serialization.py b/chord_drs/serialization.py index 467a49a..72401e6 100644 --- a/chord_drs/serialization.py +++ b/chord_drs/serialization.py @@ -7,7 +7,7 @@ from urllib.parse import urlparse from .data_sources import DATA_SOURCE_LOCAL, DATA_SOURCE_MINIO -from .models import DrsMixin, DrsBlob +from .models import DrsBlob from .types import DRSAccessMethodDict, DRSObjectBentoDict, DRSObjectDict @@ -24,7 +24,7 @@ def create_drs_uri(object_id: str) -> str: return f"drs://{get_drs_host()}/{object_id}" -def build_bento_object_json(drs_object: DrsMixin) -> DRSObjectBentoDict: +def build_bento_object_json(drs_object: DrsBlob) -> DRSObjectBentoDict: return { "project_id": drs_object.project_id, "dataset_id": drs_object.dataset_id,