-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from AllenNeuralDynamics:feat-add-types
Add data types
- Loading branch information
Showing
5 changed files
with
261 additions
and
16 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,51 @@ | ||
from enum import StrEnum | ||
from typing import Any, Optional, Literal | ||
from aind_behavior_services.base import SchemaVersionedModel | ||
from pydantic import BaseModel, Field | ||
|
||
__version__ = "0.1.0" | ||
|
||
class DataType(StrEnum): | ||
STRING = "string" | ||
NUMBER = "number" | ||
BOOLEAL = "boolean" | ||
OBJECT = "object" | ||
ARRAY = "array" | ||
NULL = "null" | ||
|
||
|
||
class TimestampSource(StrEnum): | ||
NULL = "null" | ||
HARP = "harp" | ||
RENDER = "render" | ||
|
||
|
||
class SoftwareEvent(BaseModel): | ||
""" | ||
A software event is a generic event that can be used to track any event that occurs in the software. | ||
""" | ||
|
||
name: str = Field(..., description="The name of the event") | ||
timestamp: Optional[float] = Field(..., description="The timestamp of the event") | ||
timestamp_source: TimestampSource = Field(default=TimestampSource.NULL, description="The source of the timestamp") | ||
frame_index: Optional[int] = Field(default=None, ge=0, description="The frame index of the event") | ||
frame_timestamp: Optional[float] = Field(default=None, description="The timestamp of the frame") | ||
data: Optional[Any] = Field(..., description="The data of the event") | ||
data_type: DataType = Field(default=DataType.NULL, alias="dataType", description="The data type of the event") | ||
|
||
|
||
class RenderSynchState(BaseModel): | ||
sync_quad_value: Optional[float] = Field(default=None, ge=0, le=1, description="The synchronization quad value") | ||
frame_index: Optional[int] = Field(default=None, ge=0, description="The frame index of the event") | ||
frame_timestamp: Optional[float] = Field(default=None, ge=0, description="The timestamp of the frame") | ||
|
||
|
||
class DataTypes(SchemaVersionedModel): | ||
version: Literal[__version__] = __version__ | ||
software_event: SoftwareEvent | ||
render_synch_state: RenderSynchState | ||
|
||
class Config: | ||
json_schema_extra = { | ||
"x-abstract": "True", | ||
} |
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,179 @@ | ||
{ | ||
"definitions": { | ||
"DataType": { | ||
"enum": [ | ||
"string", | ||
"number", | ||
"boolean", | ||
"object", | ||
"array", | ||
"null" | ||
], | ||
"title": "DataType", | ||
"type": "string" | ||
}, | ||
"RenderSynchState": { | ||
"properties": { | ||
"sync_quad_value": { | ||
"default": null, | ||
"description": "The synchronization quad value", | ||
"oneOf": [ | ||
{ | ||
"maximum": 1.0, | ||
"minimum": 0.0, | ||
"type": "number" | ||
}, | ||
{ | ||
"type": "null" | ||
} | ||
], | ||
"title": "Sync Quad Value" | ||
}, | ||
"frame_index": { | ||
"default": null, | ||
"description": "The frame index of the event", | ||
"oneOf": [ | ||
{ | ||
"minimum": 0, | ||
"type": "integer" | ||
}, | ||
{ | ||
"type": "null" | ||
} | ||
], | ||
"title": "Frame Index" | ||
}, | ||
"frame_timestamp": { | ||
"default": null, | ||
"description": "The timestamp of the frame", | ||
"oneOf": [ | ||
{ | ||
"minimum": 0.0, | ||
"type": "number" | ||
}, | ||
{ | ||
"type": "null" | ||
} | ||
], | ||
"title": "Frame Timestamp" | ||
} | ||
}, | ||
"title": "RenderSynchState", | ||
"type": "object" | ||
}, | ||
"SoftwareEvent": { | ||
"description": "A software event is a generic event that can be used to track any event that occurs in the software.", | ||
"properties": { | ||
"name": { | ||
"description": "The name of the event", | ||
"title": "Name", | ||
"type": "string" | ||
}, | ||
"timestamp": { | ||
"description": "The timestamp of the event", | ||
"oneOf": [ | ||
{ | ||
"type": "number" | ||
}, | ||
{ | ||
"type": "null" | ||
} | ||
], | ||
"title": "Timestamp" | ||
}, | ||
"timestamp_source": { | ||
"allOf": [ | ||
{ | ||
"$ref": "#/definitions/TimestampSource" | ||
} | ||
], | ||
"default": "null", | ||
"description": "The source of the timestamp" | ||
}, | ||
"frame_index": { | ||
"default": null, | ||
"description": "The frame index of the event", | ||
"oneOf": [ | ||
{ | ||
"minimum": 0, | ||
"type": "integer" | ||
}, | ||
{ | ||
"type": "null" | ||
} | ||
], | ||
"title": "Frame Index" | ||
}, | ||
"frame_timestamp": { | ||
"default": null, | ||
"description": "The timestamp of the frame", | ||
"oneOf": [ | ||
{ | ||
"type": "number" | ||
}, | ||
{ | ||
"type": "null" | ||
} | ||
], | ||
"title": "Frame Timestamp" | ||
}, | ||
"data": { | ||
"description": "The data of the event", | ||
"oneOf": [ | ||
{}, | ||
{ | ||
"type": "null" | ||
} | ||
], | ||
"title": "Data" | ||
}, | ||
"dataType": { | ||
"allOf": [ | ||
{ | ||
"$ref": "#/definitions/DataType" | ||
} | ||
], | ||
"default": "null", | ||
"description": "The data type of the event" | ||
} | ||
}, | ||
"required": [ | ||
"name", | ||
"timestamp", | ||
"data" | ||
], | ||
"title": "SoftwareEvent", | ||
"type": "object" | ||
}, | ||
"TimestampSource": { | ||
"enum": [ | ||
"null", | ||
"harp", | ||
"render" | ||
], | ||
"title": "TimestampSource", | ||
"type": "string" | ||
} | ||
}, | ||
"properties": { | ||
"version": { | ||
"const": "0.1.0", | ||
"default": "0.1.0", | ||
"title": "Version", | ||
"type": "string" | ||
}, | ||
"software_event": { | ||
"$ref": "#/definitions/SoftwareEvent" | ||
}, | ||
"render_synch_state": { | ||
"$ref": "#/definitions/RenderSynchState" | ||
} | ||
}, | ||
"required": [ | ||
"software_event", | ||
"render_synch_state" | ||
], | ||
"title": "DataTypes", | ||
"type": "object", | ||
"x-abstract": "True" | ||
} |