-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
converter from json to
TypedDict
and BaseModel
- Loading branch information
1 parent
acd40a9
commit 4f40113
Showing
46 changed files
with
2,325 additions
and
1,265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# generated in `event_model/generate` | ||
|
||
from typing import Tuple, Type, Union | ||
|
||
from .bulk_datum import * # noqa: F403 | ||
from .bulk_events import * # noqa: F403 | ||
from .datum import * # noqa: F403 | ||
from .datum_page import * # noqa: F403 | ||
from .event import * # noqa: F403 | ||
from .event_descriptor import * # noqa: F403 | ||
from .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 | ||
from .stream_datum import * # noqa: F403 | ||
from .stream_resource import * # noqa: F403 | ||
|
||
BasemodelType = Union[ | ||
Type[BulkDatum], # noqa: F405, | ||
Type[BulkEvents], # noqa: F405, | ||
Type[Datum], # noqa: F405, | ||
Type[DatumPage], # noqa: F405, | ||
Type[Event], # noqa: F405, | ||
Type[EventDescriptor], # noqa: F405, | ||
Type[EventPage], # noqa: F405, | ||
Type[PartialResource], # noqa: F405, | ||
Type[RunStart], # noqa: F405, | ||
Type[RunStop], # noqa: F405, | ||
Type[StreamDatum], # noqa: F405, | ||
Type[StreamResource], # noqa: F405, | ||
Type[Resource], # noqa: F405, | ||
] | ||
|
||
ALL_BASEMODELS: Tuple[BasemodelType, ...] = ( | ||
BulkDatum, # noqa: F405 | ||
BulkEvents, # noqa: F405 | ||
Datum, # noqa: F405 | ||
DatumPage, # noqa: F405 | ||
Event, # noqa: F405 | ||
EventDescriptor, # noqa: F405 | ||
EventPage, # noqa: F405 | ||
PartialResource, # noqa: F405 | ||
RunStart, # noqa: F405 | ||
RunStop, # noqa: F405 | ||
StreamDatum, # noqa: F405 | ||
StreamResource, # noqa: F405 | ||
Resource, # noqa: F405 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# ruff: noqa | ||
# type: ignore | ||
# generated by datamodel-codegen: | ||
# filename: bulk_datum.json | ||
|
||
from __future__ import annotations | ||
|
||
from typing import Any, Dict, List | ||
|
||
from pydantic import BaseModel, ConfigDict | ||
|
||
|
||
class BulkDatum(BaseModel): | ||
""" | ||
Document to reference a quanta of externally-stored data | ||
""" | ||
|
||
model_config = ConfigDict( | ||
extra="forbid", | ||
) | ||
datum_kwarg_list: List[Dict[str, Any]] | ||
""" | ||
Array of arguments to pass to the Handler to retrieve one quanta of data | ||
""" | ||
resource: str | ||
""" | ||
UID of the Resource to which all these Datum documents belong | ||
""" | ||
datum_ids: List[str] | ||
""" | ||
Globally unique identifiers for each Datum (akin to 'uid' for other Document types), typically formatted as '<resource>/<integer>' | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# ruff: noqa | ||
# type: ignore | ||
# generated by datamodel-codegen: | ||
# filename: bulk_events.json | ||
|
||
from __future__ import annotations | ||
|
||
from typing import Any, Dict, List, Optional | ||
|
||
from pydantic import BaseModel, ConfigDict, Field, RootModel | ||
|
||
|
||
class BulkEvent(BaseModel): | ||
""" | ||
Document to record a quanta of collected data | ||
""" | ||
|
||
model_config = ConfigDict( | ||
extra="forbid", | ||
) | ||
data: Dict[str, Any] | ||
""" | ||
The actual measurement data | ||
""" | ||
timestamps: Dict[str, Any] | ||
""" | ||
The timestamps of the individual measurement data | ||
""" | ||
filled: Optional[Dict[str, Any]] = None | ||
""" | ||
Mapping the keys of externally-stored data to a boolean indicating whether that data has yet been loaded | ||
""" | ||
descriptor: str | ||
""" | ||
UID to point back to Descriptor for this event stream | ||
""" | ||
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 | ||
""" | ||
uid: str | ||
""" | ||
Globally unique identifier for this Event | ||
""" | ||
|
||
|
||
class BulkEvents(RootModel[Dict[str, List[BulkEvent]]]): | ||
root: Dict[str, List[BulkEvent]] = Field(..., title="bulk_events") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# ruff: noqa | ||
# type: ignore | ||
# generated by datamodel-codegen: | ||
# filename: datum.json | ||
|
||
from __future__ import annotations | ||
|
||
from typing import Any, Dict | ||
|
||
from pydantic import BaseModel, ConfigDict, Field | ||
|
||
|
||
class Datum(BaseModel): | ||
""" | ||
Document to reference a quanta of externally-stored data | ||
""" | ||
|
||
model_config = ConfigDict( | ||
extra="forbid", | ||
) | ||
datum_id: str = Field(..., title="Datum Id") | ||
""" | ||
Globally unique identifier for this Datum (akin to 'uid' for other Document types), typically formatted as '<resource>/<integer>' | ||
""" | ||
datum_kwargs: Dict[str, Any] = Field(..., title="Datum Kwargs") | ||
""" | ||
Arguments to pass to the Handler to retrieve one quanta of data | ||
""" | ||
resource: str = Field(..., title="Resource") | ||
""" | ||
The UID of the Resource to which this Datum belongs | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# ruff: noqa | ||
# type: ignore | ||
# generated by datamodel-codegen: | ||
# filename: datum_page.json | ||
|
||
from __future__ import annotations | ||
|
||
from typing import Dict, List | ||
|
||
from pydantic import BaseModel, ConfigDict, Field, RootModel | ||
|
||
|
||
class DataFrameForDatumPage(RootModel[List[str]]): | ||
root: List[str] = Field(..., title="DataFrameForDatumPage") | ||
|
||
|
||
class DatumPage(BaseModel): | ||
""" | ||
Page of documents to reference a quanta of externally-stored data | ||
""" | ||
|
||
model_config = ConfigDict( | ||
extra="forbid", | ||
) | ||
datum_id: DataFrameForDatumPage | ||
""" | ||
Array unique identifiers for each Datum (akin to 'uid' for other Document types), typically formatted as '<resource>/<integer>' | ||
""" | ||
datum_kwargs: Dict[str, List] = Field(..., title="Datum Kwargs") | ||
""" | ||
Array of arguments to pass to the Handler to retrieve one quanta of data | ||
""" | ||
resource: str = Field(..., title="Resource") | ||
""" | ||
The UID of the Resource to which all Datums in the page belong | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# ruff: noqa | ||
# type: ignore | ||
# generated by datamodel-codegen: | ||
# filename: event.json | ||
|
||
from __future__ import annotations | ||
|
||
from typing import Any, Dict, Optional, Union | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
|
||
class PartialEvent(BaseModel): | ||
data: Dict[str, Any] = Field(..., title="data") | ||
""" | ||
The actual measurement data | ||
""" | ||
filled: Optional[Dict[str, Union[bool, str]]] = Field(None, title="filled") | ||
""" | ||
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) | ||
""" | ||
time: float = Field(..., title="time") | ||
""" | ||
The event time. This maybe different than the timestamps on each of the data entries. | ||
""" | ||
timestamps: Dict[str, Any] = Field(..., title="timestamps") | ||
""" | ||
The timestamps of the individual measurement data | ||
""" | ||
|
||
|
||
class Event(PartialEvent): | ||
""" | ||
Document to record a quanta of collected data | ||
""" | ||
|
||
descriptor: str = Field(..., title="descriptor") | ||
""" | ||
UID of the EventDescriptor to which this Event belongs | ||
""" | ||
seq_num: int = Field(..., title="seq_num") | ||
""" | ||
Sequence number to identify the location of this Event in the Event stream | ||
""" | ||
uid: str = Field(..., title="uid") | ||
""" | ||
Globally unique identifier for this Event | ||
""" |
Oops, something went wrong.