Source code for simpleml.orm.pipeline

"""
ORM module for pipeline objects
"""

[docs]__author__ = "Elisha Yadgaran"
import logging from sqlalchemy import Column, ForeignKey, Index, UniqueConstraint from sqlalchemy.orm import relationship from simpleml.orm.dataset import ORMDataset from simpleml.orm.persistable import ORMPersistable from simpleml.orm.sqlalchemy_types import GUID, MutableJSON
[docs]LOGGER = logging.getLogger(__name__)
[docs]class ORMPipeline(ORMPersistable): """ Base class for all Pipeline objects. ------- Schema ------- params: pipeline parameter metadata for easy insight into hyperparameters across trainings dataset_id: foreign key relation to the dataset used as input """
[docs] __tablename__ = "pipelines"
# Additional pipeline specific metadata
[docs] params = Column(MutableJSON)
[docs] dataset_id = Column( GUID, ForeignKey("datasets.id", name="pipelines_dataset_id_fkey")
)
[docs] dataset = relationship( "ORMDataset", enable_typechecks=False, foreign_keys=[dataset_id]
)
[docs] __table_args__ = ( # Unique constraint for versioning UniqueConstraint("name", "version", name="pipeline_name_version_unique"), # Index for searching through friendly names Index("pipeline_name_index", "name"),
) @classmethod
[docs] def load_dataset(cls, id: str): return cls.load_reference(ORMDataset, id)