Skip to content

Commit

Permalink
Maintained parent class Partial in jsonschema
Browse files Browse the repository at this point in the history
  • Loading branch information
evalott100 committed Jan 13, 2025
1 parent aa94a32 commit 4598584
Show file tree
Hide file tree
Showing 32 changed files with 320 additions and 442 deletions.
9 changes: 3 additions & 6 deletions src/event_model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

from .documents.datum import Datum
from .documents.datum_page import DatumPage
from .documents.event import Event
from .documents.event import Event, PartialEvent
from .documents.event_descriptor import (
Configuration,
DataKey,
Expand All @@ -44,11 +44,8 @@
LimitsRange,
PerObjectHint,
)
from .documents.event_page import EventPage
from .documents.partial_event import PartialEvent
from .documents.partial_event_page import PartialEventPage
from .documents.partial_resource import PartialResource
from .documents.resource import Resource
from .documents.event_page import EventPage, PartialEventPage
from .documents.resource import PartialResource, Resource
from .documents.run_start import (
CalculatedEventProjection,
Calculation,
Expand Down
2 changes: 1 addition & 1 deletion src/event_model/basemodels/datum.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class Datum(BaseModel):
"""Document to reference a quanta of externally-stored data"""

model_config = ConfigDict(extra="forbid")
model_config = ConfigDict(title="datum", extra="forbid")

datum_id: Annotated[
str,
Expand Down
2 changes: 1 addition & 1 deletion src/event_model/basemodels/datum_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class DataFrameForDatumPage(RootModel):
class DatumPage(BaseModel):
"""Page of documents to reference a quanta of externally-stored data"""

model_config = ConfigDict(extra="forbid")
model_config = ConfigDict(title="datum_page", extra="forbid")

datum_id: Annotated[
DataFrameForDatumPage,
Expand Down
4 changes: 2 additions & 2 deletions src/event_model/basemodels/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class PartialEvent(BaseModel):
model_config = ConfigDict(extra="forbid")
model_config = ConfigDict(title="partial_event", extra="forbid")

data: Annotated[Dict[str, Any], Field(description="The actual measurement data")]
filled: Annotated[
Expand Down Expand Up @@ -33,7 +33,7 @@ class PartialEvent(BaseModel):
class Event(PartialEvent):
"""Document to record a quanta of collected data"""

model_config = ConfigDict(extra="forbid")
model_config = ConfigDict(title="event", extra="forbid")

descriptor: Annotated[
str, Field(description="UID of the EventDescriptor to which this Event belongs")
Expand Down
11 changes: 9 additions & 2 deletions src/event_model/basemodels/event_descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,12 @@ class DataKey(BaseModel):
Limits,
Field(
default_factory=lambda: Limits(
control=None, display=None, warning=None, alarm=None
control=None,
display=None,
warning=None,
alarm=None,
hysteresis=None,
rds=None,
),
description="Epics limits.",
),
Expand Down Expand Up @@ -251,7 +256,9 @@ class EventDescriptor(BaseModel):
documents"""

model_config = ConfigDict(
extra="allow", json_schema_extra=EVENT_DESCRIPTOR_EXTRA_SCHEMA
title="event_descriptor",
extra="allow",
json_schema_extra=EVENT_DESCRIPTOR_EXTRA_SCHEMA,
)

configuration: Annotated[
Expand Down
4 changes: 2 additions & 2 deletions src/event_model/basemodels/event_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


class PartialEventPage(BaseModel):
model_config = ConfigDict(extra="forbid")
model_config = ConfigDict(title="partial_event_page", extra="forbid")

data: Annotated[
DataFrameForEventPage,
Expand Down Expand Up @@ -44,7 +44,7 @@ class PartialEventPage(BaseModel):
class EventPage(PartialEventPage):
"""Page of documents to record a quanta of collected data"""

model_config = ConfigDict(extra="forbid")
model_config = ConfigDict(title="event_page", extra="forbid")

descriptor: Annotated[
str,
Expand Down
4 changes: 2 additions & 2 deletions src/event_model/basemodels/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class PartialResource(BaseModel):
model_config = ConfigDict(extra="forbid")
model_config = ConfigDict(title="partial_resource", extra="forbid")

spec: Annotated[
str,
Expand Down Expand Up @@ -41,7 +41,7 @@ class Resource(PartialResource):
externally-stored data
"""

model_config = ConfigDict(extra="forbid")
model_config = ConfigDict(title="resource", extra="forbid")

path_semantics: Annotated[
Literal["posix", "windows"],
Expand Down
4 changes: 3 additions & 1 deletion src/event_model/basemodels/run_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ class RunStart(BaseModel):
later documents link to it
"""

model_config = ConfigDict(extra="allow", json_schema_extra=RUN_START_EXTRA_SCHEMA)
model_config = ConfigDict(
title="run_start", extra="allow", json_schema_extra=RUN_START_EXTRA_SCHEMA
)

data_groups: Annotated[
List[str],
Expand Down
1 change: 1 addition & 0 deletions src/event_model/basemodels/run_stop.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class RunStop(BaseModel):
"""

model_config = ConfigDict(
title="run_stop",
extra="allow",
json_schema_extra=RUN_STOP_EXTRA_SCHEMA,
)
Expand Down
7 changes: 6 additions & 1 deletion src/event_model/basemodels/stream_datum.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any

from pydantic import BaseModel, Field, RootModel
from pydantic import BaseModel, ConfigDict, Field, RootModel
from typing_extensions import Annotated


Expand All @@ -24,6 +24,11 @@ class StreamRange(BaseModel):
class StreamDatum(BaseModel):
"""Document to reference a quanta of an externally-stored stream of data."""

model_config = ConfigDict(
title="stream_datum",
extra="allow",
)

descriptor: Annotated[
str,
Field(description="UID of the EventDescriptor to which this Datum belongs"),
Expand Down
7 changes: 6 additions & 1 deletion src/event_model/basemodels/stream_resource.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any, Dict

from pydantic import BaseModel, Field
from pydantic import BaseModel, ConfigDict, Field
from typing_extensions import Annotated


Expand All @@ -10,6 +10,11 @@ class StreamResource(BaseModel):
externally-stored data streams
"""

model_config = ConfigDict(
title="stream_resource",
extra="allow",
)

data_key: Annotated[
str,
Field(
Expand Down
9 changes: 0 additions & 9 deletions src/event_model/documents/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
from .event import * # noqa: F403
from .event_descriptor import * # noqa: F403
from .event_page import * # noqa: F403
from .partial_event import * # noqa: F403
from .partial_event_page import * # noqa: F403
from .partial_resource import * # noqa: F403
from .resource import * # noqa: F403
from .run_start import * # noqa: F403
from .run_stop import * # noqa: F403
Expand All @@ -22,9 +19,6 @@
Type[Event], # noqa: F405,
Type[EventDescriptor], # noqa: F405,
Type[EventPage], # noqa: F405,
Type[PartialEvent], # noqa: F405,
Type[PartialEventPage], # noqa: F405,
Type[PartialResource], # noqa: F405,
Type[Resource], # noqa: F405,
Type[RunStart], # noqa: F405,
Type[RunStop], # noqa: F405,
Expand All @@ -38,9 +32,6 @@
Event, # noqa: F405
EventDescriptor, # noqa: F405
EventPage, # noqa: F405
PartialEvent, # noqa: F405
PartialEventPage, # noqa: F405
PartialResource, # noqa: F405
Resource, # noqa: F405
RunStart, # noqa: F405
RunStop, # noqa: F405
Expand Down
29 changes: 16 additions & 13 deletions src/event_model/documents/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,15 @@
from typing_extensions import NotRequired


class Event(TypedDict):
"""
Document to record a quanta of collected data
"""

class PartialEvent(TypedDict):
data: Dict[str, Any]
"""
The actual measurement data
"""
descriptor: str
"""
UID of the EventDescriptor to which this Event belongs
"""
filled: NotRequired[Dict[str, Union[bool, str]]]
"""
Mapping each of the keys of externally-stored data to the boolean False, indicating that the data has not been loaded, or to foreign keys (moved here from 'data' when the data was loaded)
"""
seq_num: int
"""
Sequence number to identify the location of this Event in the Event stream
"""
time: float
"""
The event time. This maybe different than the timestamps on each of the data entries.
Expand All @@ -38,6 +26,21 @@ class Event(TypedDict):
"""
The timestamps of the individual measurement data
"""


class Event(PartialEvent):
"""
Document to record a quanta of collected data
"""

descriptor: str
"""
UID of the EventDescriptor to which this Event belongs
"""
seq_num: int
"""
Sequence number to identify the location of this Event in the Event stream
"""
uid: str
"""
Globally unique identifier for this Event
Expand Down
29 changes: 16 additions & 13 deletions src/event_model/documents/event_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,15 @@
from typing_extensions import NotRequired


class EventPage(TypedDict):
"""
Page of documents to record a quanta of collected data
"""

class PartialEventPage(TypedDict):
data: Dict[str, List]
"""
The actual measurement data
"""
descriptor: str
"""
The UID of the EventDescriptor to which all of the Events in this page belong
"""
filled: NotRequired[Dict[str, List[Union[bool, str]]]]
"""
Mapping each of the keys of externally-stored data to an array containing the boolean False, indicating that the data has not been loaded, or to foreign keys (moved here from 'data' when the data was loaded)
"""
seq_num: List[int]
"""
Array of sequence numbers to identify the location of each Event in the Event stream
"""
time: List[float]
"""
Array of Event times. This maybe different than the timestamps on each of the data entries
Expand All @@ -38,6 +26,21 @@ class EventPage(TypedDict):
"""
The timestamps of the individual measurement data
"""


class EventPage(PartialEventPage):
"""
Page of documents to record a quanta of collected data
"""

descriptor: str
"""
The UID of the EventDescriptor to which all of the Events in this page belong
"""
seq_num: List[int]
"""
Array of sequence numbers to identify the location of each Event in the Event stream
"""
uid: List[str]
"""
Array of globally unique identifiers for each Event
Expand Down
28 changes: 0 additions & 28 deletions src/event_model/documents/partial_event.py

This file was deleted.

28 changes: 0 additions & 28 deletions src/event_model/documents/partial_event_page.py

This file was deleted.

30 changes: 0 additions & 30 deletions src/event_model/documents/partial_resource.py

This file was deleted.

Loading

0 comments on commit 4598584

Please sign in to comment.