Skip to content

Commit

Permalink
refact: remove redundant DrsMixin class
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlougheed committed Jul 17, 2024
1 parent ab3a7b1 commit 725b28e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
16 changes: 7 additions & 9 deletions chord_drs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,25 @@
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
dataset_id = Column(String(64), nullable=True) # Nullable for backwards-compatibility / project-only stuff?
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

Expand Down
4 changes: 2 additions & 2 deletions chord_drs/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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,
Expand Down

0 comments on commit 725b28e

Please sign in to comment.