Skip to content

Commit

Permalink
refactor: remove the Meta in Metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
dbirman committed Jan 14, 2025
1 parent 3c7ccc2 commit 19ca120
Show file tree
Hide file tree
Showing 24 changed files with 158 additions and 158 deletions.
2 changes: 1 addition & 1 deletion src/aind_data_schema/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" imports for MetadataModel subclasses
""" imports for DataModel subclasses
"""

__version__ = "2.0.0"
6 changes: 3 additions & 3 deletions src/aind_data_schema/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def validate_fieldnames(self):
GenericModelType = TypeVar("GenericModelType", bound=GenericModel)


class MetadataModel(BaseModel, Generic[GenericModelType]):
class DataModel(BaseModel, Generic[GenericModelType]):
"""BaseModel that disallows extra fields
Also performs validation checks / coercion / upgrades where necessary
Expand Down Expand Up @@ -130,7 +130,7 @@ def unit_validator(cls, values):
return values


class MetadataCoreModel(MetadataModel):
class DataCoreModel(DataModel):
"""Generic base class to hold common fields/validators/etc for all basic AIND schema"""

_FILE_EXTENSION = PrivateAttr(default=".json")
Expand All @@ -155,7 +155,7 @@ def default_filename(cls):
Returns standard filename in snakecase
"""
parent_classes = [
base_class for base_class in cls.__bases__ if base_class.__name__ != MetadataCoreModel.__name__
base_class for base_class in cls.__bases__ if base_class.__name__ != DataCoreModel.__name__
]

name = cls.__name__
Expand Down
22 changes: 11 additions & 11 deletions src/aind_data_schema/components/coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pydantic import Field
from typing_extensions import Annotated

from aind_data_schema.base import MetadataModel
from aind_data_schema.base import DataModel


class CcfVersion(str, Enum):
Expand Down Expand Up @@ -45,7 +45,7 @@ class AnatomicalDirection(str, Enum):
OTHER = "Other"


class CoordinateTransform(MetadataModel):
class CoordinateTransform(DataModel):
"""Generic base class for coordinate transform subtypes"""

type: str = Field(..., title="transformation type")
Expand Down Expand Up @@ -83,15 +83,15 @@ class Affine3dTransform(CoordinateTransform):
)


class Size2d(MetadataModel):
class Size2d(DataModel):
"""2D size of an object"""

width: int = Field(..., title="Width")
height: int = Field(..., title="Height")
unit: SizeUnit = Field(SizeUnit.PX, title="Size unit")


class Size3d(MetadataModel):
class Size3d(DataModel):
"""3D size of an object"""

width: int = Field(..., title="Width")
Expand All @@ -100,7 +100,7 @@ class Size3d(MetadataModel):
unit: SizeUnit = Field(SizeUnit.M, title="Size unit")


class Orientation3d(MetadataModel):
class Orientation3d(DataModel):
"""3D orientation of an object"""

pitch: Decimal = Field(..., title="Angle pitch", ge=0, le=360)
Expand All @@ -109,15 +109,15 @@ class Orientation3d(MetadataModel):
unit: AngleUnit = Field(AngleUnit.DEG, title="Angle unit")


class ModuleOrientation2d(MetadataModel):
class ModuleOrientation2d(DataModel):
"""2D module orientation of an object"""

arc_angle: Decimal = Field(..., title="Arc angle")
module_angle: Decimal = Field(..., title="Module angle")
unit: AngleUnit = Field(AngleUnit.DEG, title="Angle unit")


class ModuleOrientation3d(MetadataModel):
class ModuleOrientation3d(DataModel):
"""3D module orientation of an object"""

arc_angle: Decimal = Field(..., title="Arc angle")
Expand All @@ -126,7 +126,7 @@ class ModuleOrientation3d(MetadataModel):
unit: AngleUnit = Field(AngleUnit.DEG, title="Angle unit")


class Coordinates3d(MetadataModel):
class Coordinates3d(DataModel):
"""Coordinates in a 3D grid"""

x: Decimal = Field(..., title="Position X")
Expand All @@ -135,7 +135,7 @@ class Coordinates3d(MetadataModel):
unit: SizeUnit = Field(SizeUnit.UM, title="Position unit")


class CcfCoords(MetadataModel):
class CcfCoords(DataModel):
"""Coordinates in CCF template space"""

ml: Decimal = Field(..., title="ML")
Expand All @@ -145,7 +145,7 @@ class CcfCoords(MetadataModel):
ccf_version: CcfVersion = Field(CcfVersion.CCFv3, title="CCF version")


class Axis(MetadataModel):
class Axis(DataModel):
"""Description of an axis"""

name: AxisName = Field(..., title="Axis")
Expand All @@ -168,7 +168,7 @@ class ImageAxis(Axis):
unit: SizeUnit = Field(SizeUnit.UM, title="Axis physical units")


class RelativePosition(MetadataModel):
class RelativePosition(DataModel):
"""Position and rotation of a device in a rig or instrument"""

device_position_transformations: List[
Expand Down
26 changes: 13 additions & 13 deletions src/aind_data_schema/components/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from pydantic import Field, ValidationInfo, field_validator, model_validator
from typing_extensions import Annotated

from aind_data_schema.base import GenericModel, GenericModelType, MetadataModel, AwareDatetimeWithDefault
from aind_data_schema.base import GenericModel, GenericModelType, DataModel, AwareDatetimeWithDefault
from aind_data_schema.components.coordinates import RelativePosition, Size3d
from aind_data_schema.components.reagent import Reagent

Expand Down Expand Up @@ -261,7 +261,7 @@ class MyomatrixArrayType(str, Enum):
SUTURED = "Sutured"


class Device(MetadataModel):
class Device(DataModel):
"""Generic device"""

device_type: str = Field(..., title="Device type") # Needs to be set by child classes that inherits
Expand All @@ -277,7 +277,7 @@ class Device(MetadataModel):
notes: Optional[str] = Field(default=None, title="Notes")


class Software(MetadataModel):
class Software(DataModel):
"""Description of generic software"""

name: str = Field(..., title="Software name")
Expand All @@ -286,7 +286,7 @@ class Software(MetadataModel):
parameters: GenericModelType = Field(GenericModel(), title="Software parameters")


class Calibration(MetadataModel):
class Calibration(DataModel):
"""Generic calibration class"""

calibration_date: AwareDatetimeWithDefault = Field(..., title="Date and time of calibration")
Expand All @@ -297,7 +297,7 @@ class Calibration(MetadataModel):
notes: Optional[str] = Field(default=None, title="Notes")


class Maintenance(MetadataModel):
class Maintenance(DataModel):
"""Generic maintenance class"""

maintenance_date: AwareDatetimeWithDefault = Field(..., title="Date and time of maintenance")
Expand Down Expand Up @@ -444,7 +444,7 @@ def validate_other(cls, value: Optional[str], info: ValidationInfo) -> Optional[
return value


class CameraAssembly(MetadataModel):
class CameraAssembly(DataModel):
"""Named assembly of a camera and lens (and optionally a filter)"""

# required fields
Expand All @@ -458,7 +458,7 @@ class CameraAssembly(MetadataModel):
position: Optional[RelativePosition] = Field(default=None, title="Relative position of this assembly")


class DAQChannel(MetadataModel):
class DAQChannel(DataModel):
"""Named input or output channel on a DAQ device"""

# required fields
Expand Down Expand Up @@ -560,7 +560,7 @@ class Lamp(Device):
temperature_unit: Optional[TemperatureUnit] = Field(default=None, title="Temperature unit")


class ProbePort(MetadataModel):
class ProbePort(DataModel):
"""Port for a probe connection"""

index: int = Field(..., title="One-based port index")
Expand Down Expand Up @@ -610,7 +610,7 @@ class Patch(Device):
photobleaching_date: Optional[date] = Field(default=None, title="Photobleaching date")


class LaserAssembly(MetadataModel):
class LaserAssembly(DataModel):
"""Assembly for optogenetic stimulation"""

name: str = Field(..., title="Laser assembly name")
Expand Down Expand Up @@ -638,7 +638,7 @@ class EphysProbe(Device):
headstage: Optional[Headstage] = Field(default=None, title="Headstage for this probe")


class EphysAssembly(MetadataModel):
class EphysAssembly(DataModel):
"""Module for electrophysiological recording"""

name: str = Field(..., title="Ephys assembly name")
Expand All @@ -659,7 +659,7 @@ class FiberProbe(Device):
length_unit: SizeUnit = Field(default=SizeUnit.MM, title="Length unit")


class FiberAssembly(MetadataModel):
class FiberAssembly(DataModel):
"""Module for inserted fiber photometry recording"""

name: str = Field(..., title="Fiber assembly name")
Expand Down Expand Up @@ -839,7 +839,7 @@ def validate_other(self):
return self


class RewardDelivery(MetadataModel):
class RewardDelivery(DataModel):
"""Description of reward delivery system"""

device_type: Literal["Reward delivery"] = "Reward delivery"
Expand All @@ -862,7 +862,7 @@ class ChannelType(Enum):
CARRIER = "Carrier"


class OlfactometerChannel(MetadataModel):
class OlfactometerChannel(DataModel):
"""description of a Olfactometer channel"""

channel_index: int = Field(..., title="Channel index")
Expand Down
4 changes: 2 additions & 2 deletions src/aind_data_schema/components/reagent.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
from aind_data_schema_models.pid_names import PIDName
from pydantic import Field

from aind_data_schema.base import MetadataModel
from aind_data_schema.base import DataModel


class Reagent(MetadataModel):
class Reagent(DataModel):
"""Description of reagent used in procedure"""

name: str = Field(..., title="Name")
Expand Down
16 changes: 8 additions & 8 deletions src/aind_data_schema/components/stimulus.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from aind_data_schema_models.units import ConcentrationUnit, FrequencyUnit, PowerUnit, TimeUnit
from pydantic import Field, model_validator

from aind_data_schema.base import GenericModel, GenericModelType, MetadataModel
from aind_data_schema.base import GenericModel, GenericModelType, DataModel


class PulseShape(str, Enum):
Expand All @@ -25,7 +25,7 @@ class FilterType(str, Enum):
OTHER = "Other"


class OptoStimulation(MetadataModel):
class OptoStimulation(DataModel):
"""Description of opto stimulation parameters"""

stimulus_type: Literal["Opto Stimulation"] = "Opto Stimulation"
Expand Down Expand Up @@ -53,7 +53,7 @@ class OptoStimulation(MetadataModel):
notes: Optional[str] = Field(default=None, title="Notes")


class VisualStimulation(MetadataModel):
class VisualStimulation(DataModel):
"""Description of visual stimulus parameters. Provides a high level description of stimulus."""

stimulus_type: Literal["Visual Stimulation"] = "Visual Stimulation"
Expand All @@ -71,7 +71,7 @@ class VisualStimulation(MetadataModel):
notes: Optional[str] = Field(default=None, title="Notes")


class PhotoStimulationGroup(MetadataModel):
class PhotoStimulationGroup(DataModel):
"""Description of a photostimulation group"""

group_index: int = Field(..., title="Group index")
Expand All @@ -88,7 +88,7 @@ class PhotoStimulationGroup(MetadataModel):
notes: Optional[str] = Field(default=None, title="Notes")


class PhotoStimulation(MetadataModel):
class PhotoStimulation(DataModel):
"""Description of a photostimulation session"""

stimulus_type: Literal["Photo Stimulation"] = "Photo Stimulation"
Expand All @@ -101,7 +101,7 @@ class PhotoStimulation(MetadataModel):
notes: Optional[str] = Field(default=None, title="Notes")


class OlfactometerChannelConfig(MetadataModel):
class OlfactometerChannelConfig(DataModel):
"""Description of olfactometer channel configurations"""

channel_index: int = Field(..., title="Channel index")
Expand All @@ -111,7 +111,7 @@ class OlfactometerChannelConfig(MetadataModel):
notes: Optional[str] = Field(default=None, title="Notes")


class OlfactoryStimulation(MetadataModel):
class OlfactoryStimulation(DataModel):
"""Description of a olfactory stimulus"""

stimulus_type: Literal["Olfactory Stimulation"] = "Olfactory Stimulation"
Expand All @@ -120,7 +120,7 @@ class OlfactoryStimulation(MetadataModel):
notes: Optional[str] = Field(default=None, title="Notes")


class AuditoryStimulation(MetadataModel):
class AuditoryStimulation(DataModel):
"""Description of an auditory stimulus"""

stimulus_type: Literal["Auditory Stimulation"] = "Auditory Stimulation"
Expand Down
6 changes: 3 additions & 3 deletions src/aind_data_schema/components/tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pydantic import Field
from typing_extensions import Annotated

from aind_data_schema.base import MetadataModel, AwareDatetimeWithDefault
from aind_data_schema.base import DataModel, AwareDatetimeWithDefault
from aind_data_schema.components.coordinates import (
Affine3dTransform,
Rotation3dTransform,
Expand All @@ -15,7 +15,7 @@
)


class Channel(MetadataModel):
class Channel(DataModel):
"""Description of a channel"""

channel_name: str = Field(..., title="Channel")
Expand All @@ -36,7 +36,7 @@ class Channel(MetadataModel):
description: Optional[str] = Field(default=None, title="Description")


class Tile(MetadataModel):
class Tile(DataModel):
"""Description of an image tile"""

coordinate_transformations: List[
Expand Down
10 changes: 5 additions & 5 deletions src/aind_data_schema/core/acquisition.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
from aind_data_schema_models.process_names import ProcessName
from pydantic import Field, SkipValidation, field_validator

from aind_data_schema.base import MetadataCoreModel, MetadataModel, AwareDatetimeWithDefault
from aind_data_schema.base import DataCoreModel, DataModel, AwareDatetimeWithDefault
from aind_data_schema.components.coordinates import AnatomicalDirection, AxisName, ImageAxis
from aind_data_schema.components.devices import Calibration, ImmersionMedium, Maintenance, Software
from aind_data_schema.components.tile import AcquisitionTile


class Immersion(MetadataModel):
class Immersion(DataModel):
"""Description of immersion medium"""

medium: ImmersionMedium = Field(..., title="Immersion medium")
refractive_index: Decimal = Field(..., title="Index of refraction")


class ProcessingSteps(MetadataModel):
class ProcessingSteps(DataModel):
"""Description of downstream processing steps"""

channel_name: str = Field(..., title="Channel name")
Expand All @@ -40,10 +40,10 @@ class ProcessingSteps(MetadataModel):
] = Field(...)


class Acquisition(MetadataCoreModel):
class Acquisition(DataCoreModel):
"""Description of an imaging acquisition session"""

_DESCRIBED_BY_URL = MetadataCoreModel._DESCRIBED_BY_BASE_URL.default + "aind_data_schema/core/acquisition.py"
_DESCRIBED_BY_URL = DataCoreModel._DESCRIBED_BY_BASE_URL.default + "aind_data_schema/core/acquisition.py"
describedBy: str = Field(default=_DESCRIBED_BY_URL, json_schema_extra={"const": _DESCRIBED_BY_URL})
schema_version: SkipValidation[Literal["1.0.4"]] = Field(default="1.0.4")
protocol_id: List[str] = Field(default=[], title="Protocol ID", description="DOI for protocols.io")
Expand Down
Loading

0 comments on commit 19ca120

Please sign in to comment.